#212 gluNewQuadric fails with seg violation on recent Linux x86

GLU (21)

Any call to gluNewQuadric now seems to cause a segmentation violation immediately on recent versions of 32 bit x86 Linux. I have tested this on Ubuntu Jaunty, and Arch Linux with pacman updates more recent than ~4/1/09. Identical code runs normally on Ubuntu 8.04, Arch versions from 2008, and any version of Mac OS X. I thus assume this is a compatibility issue with recent changes in xorg or OpenGL.

My app uses PyOpenGL 3.0.0 with the glcanvas context provided by wxWidgets Based on my testing, however, I don't think wx is involved in the crash. I can duplicate the segv with 100% reliability in highly reduced scripts that call gluNewQuadric. I can also run the full program simply by commenting out the call to gluNewQuadric, and subsequently drawing points and lines instead of spheres and cylinders.


  • Graham Cummins

    Graham Cummins - 2009-07-02

    Workaround found:

    This failure does not occur if there is a currently active GL context with a defined size. My app uses a class that creates a Quadric on class initialization, which may occur before creating the GLCanvas the class will eventually draw in. My test scripts don't use a drawing context at all - just import GLU and call gluNewQuadric. If I postpone creation of the Quadric until after the GLCanvas is created, sized, and SetCurrent, then there is no problem. I am testing with the wxPython GLCanvas context. I guess the same behavior would apply to OpenGLContext, but I haven't tested that.

    I still consider this a minor bug, or at least a documentation failure. Creating a Quadric object (without using it to draw anything) shouldn't really require an active drawing context. It doesn't on Windows, Mac, and earlier versions of X11. If it is a new design decision to prevent this on X11 it should A) be documented somewhere, and B) fail with a Python exception, rather than a seg fault if possible. However, now that I know about this, it is a pretty easy workaround to simply create the Quadric only when it is needed to draw something immediately, so the segv doesn't pose any serious problems for me anymore.

  • Mike C. Fletcher

    Don't see the bug on 64-bit Ubuntu Jaunty with bzr head (Demo/NeHe/lesson18.py works), will have to get a 32-bit version to test with.

  • Mike C. Fletcher

    Ah, sorry, missed the comment. Recent X11 mesas are *very* picky about GL calls before context initialization, probably 3/4 of the OpenGL API will cause seg-faults if called before context init. Guess I need to be helping people with this somehow...

  • Mike C. Fletcher

    I've added an optional flag CHECK_CONTEXT, which will do explicit checks for context before running any function.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks