PDA

View Full Version : Segmentation fault in glDisable



cali1981
03-15-2006, 02:35 AM
Hi all! I have a very big problem. I'm using glut in an application, and everything went fine. But today suddently I get a segmentation fault when the application calls glDisable in setupGL function. It only does some glDisable calls...

Any idea?

Thanks in advance!

RigidBody
03-15-2006, 11:09 AM
glDisable(GL_WHAT?)

Overmind
03-15-2006, 01:54 PM
What did you change so you get a segfault now?

What's your graphic card?

A segfault in a gl-call is most likely a driver bug, since the library is supposed to catch every error. Try installing the latest driver for your card (or if you recently installed the latest driver, go back a version).

The only reason why the segfault could be your fault (at least the only one I can think of) is when you pass an invalid pointer to a function, or some similar memory corruption problem. Make sure you don't do that ;)

Comment out code until the segfault is gone, then start commenting in the code again, until you know which call causes the segfault (the cause is most likely not the glDisable call itself, but some earlier call that breaks something).

cali1981
03-16-2006, 12:54 AM
No, I commented the setupGL function that contains only glDisable and glPixelTransferi and it works. This functions contains only:

static void setupGL(void)
{
glDisable(GL_ALPHA_TEST);
....

and the segmentation fault is at the first glDisable. If I comment he first glDisable, I have another segmentation fault at the second one. My PC is an Acer notebook. I installed the latest driver from the ATI site, I think I'll try to go back and see....

Thanks for the help!

Overmind
03-16-2006, 01:02 AM
As I said, the glDisable is not the cause of the problem...

Try commenting out code that comes before setupGL. Also make sure that you have a valid rendering context when the function gets called.

cali1981
03-16-2006, 01:05 AM
No, I commented the setupGL function that contains only glDisable and glPixelTransferi and it works. This functions contains only:

static void setupGL(void)
{
glDisable(GL_ALPHA_TEST);
....

and the segmentation fault is at the first glDisable. If I comment he first glDisable, I have another segmentation fault at the second one. My PC is an Acer notebook. I installed the latest driver from the ATI site, I think I'll try to go back and see....

Thanks for the help!

cali1981
03-16-2006, 01:30 AM
I was looking ot the output of the application and I found out this:

if I uncomment the setupGL function, I get the segmfault and this error:

0xb6f62e09 in glGetString () from /usr/X11R6/lib/libGL.so.1

but if I comment it, it seems to load a different library:

Loading required GL library /usr/lib/libGL.so.1

I think it's the problem right? Is it normal I have two copies of the same library?

Ehsan Kamrani
03-16-2006, 01:49 AM
Can you post your code?
-Ehsan-

cali1981
03-16-2006, 02:16 AM
Here's where i get thesegmentation fault:

static void setupGL(void)
{

// Disable stuff that's likely to slow down glDrawPixels.
// (Omit as much of this as possible, when you know in advance
// that the OpenGL state will already be set correctly.)

glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisable(GL_DITHER);
glDisable(GL_FOG);
glDisable(GL_LIGHTING);
glDisable(GL_LOGIC_OP);
glDisable(GL_STENCIL_TEST);
glDisable(GL_TEXTURE_1D);
glDisable(GL_TEXTURE_2D);
glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
glPixelTransferi(GL_MAP_STENCIL, GL_FALSE);
glPixelTransferi(GL_RED_SCALE, 1);
glPixelTransferi(GL_RED_BIAS, 0);
glPixelTransferi(GL_GREEN_SCALE, 1);
glPixelTransferi(GL_GREEN_BIAS, 0);
glPixelTransferi(GL_BLUE_SCALE, 1);
glPixelTransferi(GL_BLUE_BIAS, 0);
glPixelTransferi(GL_ALPHA_SCALE, 1);
glPixelTransferi(GL_ALPHA_BIAS, 0);
glPixelStorei(GL_PACK_ALIGNMENT, 8);
glPixelStorei(GL_UNPACK_ALIGNMENT, 8);


// Disable extensions that could slow down glDrawPixels.

const GLubyte* extString = glGetString(GL_EXTENSIONS);

if (extString != NULL) {
if (strstr((char*) extString, "GL_EXT_convolution") != NULL) {
glDisable(GL_CONVOLUTION_1D_EXT);
glDisable(GL_CONVOLUTION_2D_EXT);
glDisable(GL_SEPARABLE_2D_EXT);
}
if (strstr((char*) extString, "GL_EXT_histogram") != NULL) {
glDisable(GL_HISTOGRAM_EXT);
glDisable(GL_MINMAX_EXT);
}
if (strstr((char*) extString, "GL_EXT_texture3D") != NULL) {
glDisable(GL_TEXTURE_3D_EXT);
}
}
}

If I comment the first n lines, I always get the same error at the next one. If I comment them all, I dont get the error. As I said before, I think the problem is something related to the two libraries...