I have a weird problem with multithread application on i915 chipset (i810 DRI driver). Application segfaults when trying to use OpenGL functions from second thread.
All necessary initialization is perfomed in application, ie XInitThreads, etc.
Tested on Suse 10.1 (xorg 6.8, 20050225 i810 driver) and Gentoo LiveDVD (xorg 7.0, 1.4.2 i810 driver).
This code works fine with NVidia drivers.
Is this a driver bug? a Mesa bug? a well-known bug that nobody is going to fix in near future? Or this is my programming error?
Hard to say like that. You code is syntactically and sementically right.
I personally don’t use X synchronization functions but what you’ve done should be correct.
Also I’m almost sure this is not a bug from X neither from Mesa (but if you have a very old Mesa version). Maybe an i810 driver bug but really hard to say even if I remember there have had some workarounds with such drivers (but for other reasons, like GL compatibilities).
So I can make only guesses. Do you define _REENTRANT when compiling (assuming you use pthreads) ? What’s your glx version ? Did you tried to debug your program ?
Finally, it’s best to unlock the display before making an exit when you encounter a problem, mainly if it’s not in the main thread just because the main thread will continue to work and will indefinately wait for the display release which will never happen.
Try to use the VESA drivers instead of i810 (should be Driver “vesa” or so in /etc/X11/xorg.conf, make a search as I can’t confirm it). These are generic drivers, so should work okay with threads.
I wasn’t saying you should switch to VESA. I tried to mean that you could test under VESA.
So as you have the same errors on different drivers, the problem might come, as you said, from xorg.
So what you could try for the moment, is simply to create a new context inside your thread. However, I’m really unsure about the result (should work okay on non-buggy environments).