GLX Error on NVidia Drivers when using Irrlicht & Allegro


I was recently working on a program that used Irrlicht for graphics and Allegro for windowing and input systems when I noticed that the app would simply fail to start due to a GLX error:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  31 (X_GLXCreateWindow)
  Serial number of failed request:  22
  Current serial number in output stream:  23

That system is currently running Linux Mint 17 with a NVidia GT 630 using the 346.82 driver. This issue has been reproduced on the following systems:

  • Linux Mint 17 AMD64, NVidia GT 630 using the 346.82 driver.
  • Gentoo Linux AMD64, NVidia GT 630 using the 352.30 driver. (This was my system before I switched to Linux Mint in hopes of shaking this issue)
  • Fedora 22, NVidia GT640 using the 352.41 driver
  • Gentoo Linux AMD64, NVidia GTX 660 using the 352.30 driver.
  • Gentoo Linux AMD64, NVidia GTX 460 using the 352.30 driver.
  • I’ve written some test code that reproduces the issue as minimally as possible and distributed it to as many Linux boxes as I can and found some additional info. It works correctly on the following systems:

  • Xubuntu 14.04.3 AMD HD7570 driver version 15.20.1013
  • Gentoo Linux AMD64, Intel GM945
  • Mac Mini Ubuntu 14.04 LTS 32bit, Intel GM945 (however seems to suffer the X11 segfault)
  • Fedora 22, Intel HD Graphics 4000 (suffers from the X11 segfault)
  • However, it was noted that some systems using the XOrg OpenGL driver would run the app fine but then X11 would segfault upon normal exits which seems to be due to some cleanup that Allegro does which happens to trigger the segfault. However, it appears to be more than Allegro because simply letting the app exit normally triggers the fault as well. I’ve ran some debugging on my old Gentoo installation and traced it down to three areas in Allegro which trigger the fault:

  • There is an fclose call in Allegro's log cleanup that for some reason triggers it:
  • There is a code segment where Allegro loads a function pointer but I can't step into the call because of the segfault:
  • X11 segfaults if the app exits and you don't call Allegro's cleanup or skip the explicit triggers and the app exits normally.
  • I’ve tried tracing the issue myself for 3 weeks and have not come up with anything helpful (The stack trace X11 produced was pretty much pointless, there was no symbols and I couldn’t get it to include any) but either issue should be easily reproducible with this code:

    #include <iostream>
    #include <irrlicht/irrlicht.h>
    #include <irrlicht/driverChoice.h>
    #include <allegro5/allegro.h>
    #include <allegro5/allegro_x.h>
    int main(int argc, char* argv[])
        irr::video::E_DRIVER_TYPE driverType = irr::driverChoiceConsole();
        // Init Allegro & create a display
        ALLEGRO_DISPLAY* allegroDisplay = al_create_display(640, 480);
        if (!allegroDisplay)
            std::cout << "Failed to create Allegro Display" << std::endl;
            return -1;
        al_set_window_title(allegroDisplay, "Allegro/Irrlicht Test");
        // Setup the creation parameters
        irr::SIrrlichtCreationParameters creationParameters;
        creationParameters.DriverType = driverType; // If this is EDT_BURNINGSIDEO or EDT_SOFTWARE, it behaves as expected.
        creationParameters.WindowId = reinterpret_cast<void*>(al_get_x_window_id(allegroDisplay));
        // Init Irrlicht
        irr::IrrlichtDevice* irrlicht = irr::createDeviceEx(creationParameters);
        irr::scene::ISceneManager* scene = irrlicht->getSceneManager();
        irr::video::IVideoDriver* video = irrlicht->getVideoDriver();
        // Setup a scene so we can see if it actually renders
        irr::scene::ISceneNode* cube = scene->addCubeSceneNode();
        cube->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        cube->setPosition(irr::core::vector3df(0, 0, 50));
        // Roll out a basic draw loop
        while (irrlicht->run())
        al_uninstall_system(); // This can segfault X11 on Nouveau in two places
        return 0; // This segfaults X11 on Nouveau for some reason, it might be file descriptors being cleaned up (Which al_uninstall_system does for its logging and that segfaults X11)

    If you don’t want to build it, I’ve got a prebuilt test attached to the post (but it might not work on all systems). cd to the root of wherever its extracted and run the script and select the OpenGL driver in the console when prompted.

    If you want to build it, make sure you’ve got any version of Irrlicht development libraries installed on your system from the respective sources. You will then need to hand-build a GitHub copy of Allegro5 because the al_get_x_window_id function does not exist in non-unstable builds of Allegro5 at the moment. After that, you can build the test code inlined in my post however you like, linking against the Allegro5 libs you built. Run the new executable you’ve made and select the OpenGL driver in your console when prompted.

    There is two related problems here, where one is the GLX error with NVidia’s drivers (Which is likely helped by someone here at NVidia) and the other is an X11 segfault which is likely specific to Novueau.

    Thanks in advance!

    It’s been noted that the original idea of Nouveau causing the X11 segfault appears to be wrong, because I’ve recently tried the test app on a Mac Mini running Ubuntu and its desktop crashed under the same circumstances mentioned above. But again, that seems to be an issue independent of NVidia’s jurisdiction. Though, now I’m not exactly sure where to point that bug report – probably at X11 it would seem.
    nvidia-bug-report.log.gz (72.6 KB)
    ALTest.tar.gz (3.61 MB)