Why am I getting a segmentation fault when using GLEW 1.10.0 ? (I've provided details of my system at the bottom of the question.)
I downloaded and compiled GLEW. The compilation (make all) and the installation (sudo make install.all) work and show no errors. The GLEW lib is installed into /usr/lib64/libGLEW.so.1.10.0.
I create a simple OpenGL test program (see below) that uses GLEW and glfw3 (3.0.3). When the program uses the installed GLEW lib, the segmentation fault happens. When I use the GLEW source code in my test program, the program works.
However if I load shaders and then query the compiled OpenGL program using glGetProgramInterfaceiv I again get a segmentation fault.

The segmentation fault happens when

  1. running glewinfo
  2. running visualinfo
  3. test program (details below)
  4. calling glGetProgramInterfaceiv (details below)

Below is the test program that uses the installed GLEW library and glfw3 (3.0.3)

#include #include int main(){glfwInit();GLFWwindow* window = glfwCreateWindow(640, 480, "Hello World", NULL,NULL);glfwMakeContextCurrent(window);glewInit ();glfwTerminate();}To compile:

g++ -o "Basic" "main.cpp" -lglfw3 -lGLEW -lGL -lX11 -lrt -lXxf86vm -lXrandrBefore running ./Basic I set

export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib64(otherwise it cannot find the GLEW lib which lives in /usr/lib64)
The program gives a segmentation fault. If I run the program through eclipse, the stack trace is:

Thread [1] 16728 [core: 2] (Suspended : Signal : SIGSEGV:Segmentation fault) 0x7ffff65e5ca0 __driCreateNewScreen_20050727() at 0x7ffff3de52f6 0x7ffff7645c92 glXQueryVersion() at 0x7ffff763d0aa _glfwInitContextAPI() at 0x40c580 _glfwPlatformInit() at 0x408855 glfwInit() at 0x404829 main() at main.cpp:7 0x403819 Using the gdb gives backtrace #0 0x00007ffff65e5ca0 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff3de52f6 in __driCreateNewScreen_20050727 () from /usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so #2 0x00007ffff7980c92 in ?? () from /usr/lib64/libGL.so.1 #3 0x00007ffff79780aa in glXQueryVersion () from /usr/lib64/libGL.so.1 #4 0x000000000040c580 in _glfwInitContextAPI () #5 0x0000000000408855 in _glfwPlatformInit () #6 0x0000000000404829 in glfwInit () #7 0x0000000000403819 in main ()
When not using the GLEW library but the source code (glew.h and glew.c) the program works. For this to work I change the first include to

#include When linking this time I use the library Xi (-lXi). The g++ commands to compile and link the program are:

g++ -I"./" -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "main.cpp"g++ -I"./" -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -MMD -MP -MF"glew.d" -MT"glew.d" -o "glew.o" "glew.c"g++ -o Basic ./glew.o ./main.o -lGL -lX11 -lXrandr -lXxf86vm -lrt -lglfw3 -lXiBefore running ./Basic I set

export LD_LIBRARY_PATH=/usr/local/lib(otherwise I get the segmentation fault, because it's trying to use the installed GLEW lib )This program does not throw the segmentation fault. The program also runs using eclipse.

Details when calling glGetProgramInterfaceiv(program, GL_PROGRAM_OUTPUT, GL_ACTIVE_RESOURCES, &outputs);
To the above test program I add code to load a vertex and fragment shaders. I compile the shaders into a program. This all works. Calling glGetShaderInfoLog works and prints the log. When I add a line of code that calls glGetProgramInterfaceiv the program gives a segmentation fault. Using glewExperimental = GL_TRUE; does not help.

OS details:

  • Linux: 3.2.0-4-amd64
  • Distro: Debian 7.3 Wheezy
  • uname -m: x86_64
  • /proc/cpuinfo -> flags parameter -> lm value present

Compiler details

  • g++ --version: g++ (Debian 4.7.2-5) 4.7.2

OpenGL details:

  • OpenGL Provider: Advanced Micro Devices (from AMD Catalyst Control Center)
  • OpenGL Renderer: AMD Radeon HD 7600M Series (from AMD Catalyst Control Center)
  • OpenGL Version: 4.2.11762 Compatibility Profile Context (from AMD Catalyst Control Center)
  • glxinfo:
  • server glx version string: 1.4
  • client glx version string: 1.4
  • GLX version: 1.4
  • OpenGL version string: 4.2.11762 Compatibility Profile Context
  • OpenGL shading language version string: 4.20
  • server glx vendor string: ATI
  • client glx vendor string: ATI

Details for the libraries used in the test program - -lglfw /usr/local/lib/libglfw3.a 3.0.3

  • -lGL there are 2 on my system libGL.so.1.2 -> /usr/lib64/fglrx/fglrx-libGL.so.1.2 and libGL.so.1.2 -> /usr/lib/i386-linux-gnu/fglrx/fglrx-libGL.so.1.2
  • -lX11 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
  • -lrt /usr/lib/x86_64-linux-gnu/librt.so -> /lib/x86_64-linux-gnu/librt.so.1 -> /lib/x86_64-linux-gnu/librt.so.1 -> /lib/x86_64-linux-gnu/librt-2.13.so
  • -lXrandr /usr/lib/x86_64-linux-gnu/libXrandr.so.2 -> libXrandr.so.2.2.0
  • -lXxf86vm /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 -> libXxf86vm.so.1.0.0
  • -lXi /usr/lib/x86_64-linux-gnu/libXi.so.6 -> libXi.so.6.1.0

Check Solution