[In progress] Guide: fixing random crashes with ATI video cards and Blender

incipit: i don’t know if this is a definitive solution but for now it works and i have experienced no crashes at all and my system is stable.

Hi! this is my first post around here, so … hello :confused:

I have adopted a GNU/linux based OS on my computers but i had experienced some random crashes and freezes using Blender, all Blender releases from the 2.5x to the latest trunk from the svn seems to not work very well with an ATI video card: the problem was the OpenGL apparently.
By the way I have experienced the same random crashes under Windows too.

The bad thing with OpenGL is that is an industry standard but is about a “rendering system” and not really about a software environment, this mean that when someone create an OpenGL based software using a library such as GLUT or freeGLUT, the function that was used can have several implementation and the coder has no power to control this kind of implementation, the coder can only make a call and the driver and video card have to do their job as provided by the maker of that driver and that video card.
Considering this, the only real solution is to tune the driver or in better terms, under a desktop GNU/linux distribution, configuring the X server with xorg.conf.

The latest closed source driver from the official AMD-ATI website provide a tool called aticonfig or amdconfig that allows you to easly setup your xorg.conf and your desktop.

Reading the documentation about both the ATI drivers and aticonfig i found an interesting option called TLS ( Thread Local Storage ) which basically allows you to change how OpenGL works and how an API-call from an application is managed.

I found another couple of interesting feature and for this reason i post my xorg.conf, but i heavily reccomend the use of aticonfig instead of copying from my xorg.conf, i am posting my xorg.conf just to show you how this options are called.

this is my actual xorg.conf:

Section "ServerLayout"
    Identifier     "aticonfig Layout"
    Screen      0  "aticonfig-Screen[0]-0" 0 0
EndSection

Section "Module"
    Load  "glx"
EndSection

Section "Monitor"
    Identifier   "aticonfig-Monitor[0]-0"
    Option        "VendorName" "ATI Proprietary Driver"
    Option        "ModelName" "Generic Autodetecting Monitor"
    Option        "DPMS" "true"
EndSection

Section "Device"
    Identifier  "aticonfig-Device[0]-0"
    Driver      "fglrx"
    Option        "OpenGLOverlay" "on"
    Option        "Capabilities" "0x00000800"
    Option        "TexturedVideoSync" "on"
    Option        "BlockSignalsOnLock" "off"
    Option        "UseFastTLS" "off"
    BusID       "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "Default Screen"
    DefaultDepth     24
EndSection

Section "Screen"
    Identifier "aticonfig-Screen[0]-0"
    Device     "aticonfig-Device[0]-0"
    Monitor    "aticonfig-Monitor[0]-0"
    DefaultDepth     24
    SubSection "Display"
        Viewport   0 0
        Depth     24
    EndSubSection
EndSection

to know how to enable this features simply run aticonfig in a terminal and read the documentation.

you can also redirect the output to a file for an easier reading like so

aticonfig > ~/man_aticonfig.txt

Useful source:

aticonfig

or

amdconfig

how to debug an OpenGL application and obtain info

generic form

LIBGL_DEBUG=verbose /path/to/executable

pratical example

LIBGL_DEBUG=verbose ~/bin/blender

Hope this helps, if i made some mistake please let me know, english it’s not my native language.

i forgot to post my specs:

Intel Q6600 - 4core with HT @ 2.4GHz
Chipset Intel P35
ATI 5770 1Gb
8Gb RAM DDR2
Ubuntu Natty 11.04 amd64

This is the computer that I had freezes with and right now runs fine with those settings

I have found out that the freeze and the crash is related to the GNU libc library and the kernel.

The problem seems to be related directly to the function read() and consist in the EAGAIN error, after that EAGAIN error from read() the system quickly slow down, some ioctl() calls are being made returning 0 ( zero ) everytime, after ioctl() the last call is for gettid() without arguments which returns the same number ( ID ) in every single call.
After gettid() the system freezes definitely.

Since i do not think that the problem is the glibc itself or the kernel, i simply think that the I/O management with the latest drivers from ATI is the cause of the crash, and since i obtain the same behaviour from Blender under Windows i am enforced to think this way; considering this i think it’s only a waste of time continuing to debug blender or any other application in an environment with the fglrx driver installed.

I have also noticed that, with a memory controller integrated in the same die of the CPU, this driver are quite stable and do not freeze up the system, probably because of the fact that the higher performance of the memory controller could hide this bad behaviour of the official driver from AMD-ATI.