glXGetCurrentDisplay() Gives a Segmentation Fault [ Linux ]


Sorry for the re-post, I had the first post in the wrong section.

I’m currently working with OpenCL/OpenGL interop and have it working on OSX.

The only difference in the code between the two operating systems can be seen below:

cl_context_properties props[] = {
    0, 0,
    0, 0,
    0, 0,

#ifdef OCL_LINUX
    props[0] = CL_GL_CONTEXT_KHR;
    props[1] = (cl_context_properties) glXGetCurrentContext();
    props[2] = CL_GLX_DISPLAY_KHR;
    props[3] = (cl_context_properties) glXGetCurrentDisplay();
    props[4] = CL_CONTEXT_PLATFORM;
    props[5] = (cl_context_properties) pID;
#ifdef OCL_OSX
    props[1] = (cl_context_properties) CGLGetShareGroup( CGLGetCurrentContext() );

    gl_f = 1;

    context = clCreateContext(props, 0, 0, NULL, NULL, &err);
    context = clCreateContext(NULL , 1, &dID, NULL, NULL, &err);

The headers are:

#ifdef OCL_OSX

#ifdef OCL_LINUX


The overall code works perfectly using the OSX version on a macbook pro that has with an NVIDIA GeForce GT 650M

When I run this on a Linux machine with a GTX 590, I get a segmentation fault.
More specifically, when calling glXGetCurrentDisplay() I get a segmentation fault.

Here’s what GDB backtrace tells me:

(gdb) r
Starting program: /mnt/nfs-main/home/dsm5/documents/project/oclProject/examples/mesh/main 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/".
Setting of real/effective user Id to 0/0 failed
FATAL: Module fglrx not found.
Error! Fail to load fglrx kernel module! Maybe you can switch to root user to load kernel module directly
Xlib:  extension "NV-GLX" missing on display "localhost:10.0".

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000406de2 in ocl::cl::device::refresh (this=0x7fffffffe8b0) at ocl_cl.cpp:330
#2  0x0000000000406ad7 in ocl::cl::device::device (this=0x7fffffffe8b0, p=0x678fa0, d=0x679070) at ocl_cl.cpp:274
#3  0x0000000000406901 in ocl::cl::setup::getDevice (this=0x6319a0, p=1, d=0) at ocl_cl.cpp:239
#4  0x000000000040bca7 in ocl::cl::getDevice (p=1, d=0) at ocl_cl.cpp:1210
#5  0x0000000000424f4d in main (argc=1, argv=0x7fffffffea08) at main.cpp:25

If anyone can help me with this (seemingly) simple problem, I would be extremely grateful since it has been bothering me for weeks!

Any tips are more than welcome as well!

Thank you in advance!

I don’t think the missing on display is the cause of the error since glxgears runs with the same warning.