I don't know if this is an appropriate forum for this question -- please point me in the right direction if you can.

I'm porting some GL code from linux to Solaris 10 and found that it was causing segmentation faults. I've reduced the code to a single file to highlight the problem (attached as libgldebug.cpp.txt). To compile, I've been using:

Briefly, the problem seems to arise from using multithreading (pthreads) in conjunction with lib DL (dynamic linking functions). I dynamically-programatically link libGL (grabbing the function "glxChooseVisual") and call it. If I make the call in one thread only, it succeeds, but for more than one thread it seg faults in libGL.so. This same code works *fine* in Linux. I'm very confused...