glBindTexture seg faulting

Hey guys,

I’m porting my project from Mesa-6.3
to NVidia 76.76 on a 6600GT.
If it is relevant, i’m using some generic (glut) code to init renderer.

The code ran fine on Mesa… however, once ported, linked, compiled, i get a seg fault when calling my glBindTexture function.
I did a glGetError before that, didn’t turn up with anything.
Using gdb, i made sure that the handle was not off somewhere. Here’s the stack:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1275925584 (LWP 30631)]
0xb7c7ce42 in glBindTexture () from /usr/lib/libGL.so.1
(gdb) bt
#0  0xb7c7ce42 in glBindTexture () from /usr/lib/libGL.so.1
#1  0xb7fe0e8a in GPUProjPack::AddImage (this=0x814d170, in=0x891cbdc, index=0)
    at /home/joe/Sensor3D/src/GPU/GPUProjPack.cpp:106
#2  0xb7fd2962 in GPUTool::Projection (this=0xb7fe8a80, in=0x891cbdc, index=0,
    data=0x891e050 "\uffff\uffff\024\uffff\uffff*\023a\uffff\214\uffff\225\223\uffff-\227{j\233]\uffff\034\236\uffff[7Zp0L\02 5\216T\uffff\uffffm\uffffK\uffffQ @R\uffff7\003>Y]\216y\uffff\uffff\uffff\uffff^Au\uffff\uffff\uffff\221\uffff\231\234+=6\001T\237>\003\uffff\uffff\uffff\uffff\uffff\202\uffff \uffff\uffff\uffff\uffff\u07ad?\uffff\uffff\u0334lY\uffff\022(\201\177\uffff\233\uffff5\uffffR?1\uffff\221\uffff\202n\211\uffffB4\uffff}/\uffff\uffff\001\uffffS%\uffff\uffff\v5\034R>\00 1
\uffffL\u07e5\uffff'\u017c\226E\u5bb5x\uffffx-\020to\221\035~!vC\226}\235\uffffio\uffffV.\uffff\uffff3\uffff\uffff\uffff\uffff\uffffS\uffff!\207\2162\uffff\031\uffff\ 236\233^\uffff\036t^!\uffffX\uffff\221\uffffD\uffff"...)
    at /home/joe/Sensor3D/src/GPU/GPUTool.cpp:229
#3  0xb7fd84ff in GPUCameraProjector::processInput (this=0x891cc20)
    at /home/joe/Sensor3D/src/GPU/GPUCameraProjector.cpp:53
#4  0xb7fa9856 in SPDImageProcessor::testAndProcessInput (this=0x891cc20,
    scheduler=0x8069560)
    at /home/joe/Sensor3D/src/SPD/SPDImageProcessor.cpp:176
#5  0xb7fb1d2b in SPDIPScheduler::processNextIP (this=0x8069560)
    at /home/joe/Sensor3D/src/SPD/SPDIPScheduler.cpp:130
#6  0xb7fb1098 in ProcThread (ipsched=0x8069560)
    at /home/joe/Sensor3D/src/SPD/SPDIPScheduler.cpp:13
#7  0xb7c88ae0 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#8  0xb778ac9a in clone () from /lib/tls/i686/cmov/libc.so.6

Here’s the part of the code that’s returning the fault.

    if (this->image[index] == NULL) {
        this->image[index] = in;

        if ((err=glGetError())!=0) {
            cout << "GL ERROR: " << err << endl;
        }
        glBindTexture(GL_TEXTURE_2D, srcHandles[index]);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image[index]->width, image[index]->height, 0, GL_RGB,
                     GL_UNSIGNED_BYTE, image[index]->pixels);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

Calling glBindTexture in a test program worked fine.

I’m stumped :stuck_out_tongue:

It is most likely that the array image[index]->pixels is too small. The fact that is works in some configuration is only luck.

Maybe is has to do with pixel alignment issues too, search for glPixelStore{i|f}

after fooling around more, i found out that ANY gl calls were causing that error. glBegin, glFlush, glGetError all gave the same results…

Finally, taking out pthreads made the system run properly… god knows why, does opengl have issues with threads?

Joe.

UBB codes are full of suprises :slight_smile: