glfw Opengl4 demo Segmentation fault
- I'm trying to run glfw3 opengl4 demo example.
make
rm -f bin/demo
cc main.c -std=c89 -Wall -Wextra -pedantic -O2 -o bin/demo -L/usr/local/lib -lglfw3 -lGL -lm -lGLU -lGLEW
Everything compiles fine.
but then:
./bin/demo
Segmentation fault (core dumped)
I see a black window and then it closes. 2) OpenGL 3, OpenGL 2 and Sdl examples works fine.
- I'm trying to use gdb to find out where program fails:
cc main.c -ggdb -std=c89 -Wall -Wextra -pedantic -O2 -o bin/demo -L/usr/local/lib -lglfw3 -lGL -lm -lGLU -lGLEW
gdb bin/demo
run
Output:
Starting program: /home/nikita/Dev/Nuklear/demo/glfw_opengl4/bin/demo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffec1ff640 (LWP 4948)]
[New Thread 0x7fffeb9fe640 (LWP 4949)]
[New Thread 0x7fffeb1fd640 (LWP 4950)]
[New Thread 0x7fffea9fc640 (LWP 4951)]
[New Thread 0x7fffe9dfb640 (LWP 4952)]
Thread 1 "demo" received signal SIGSEGV, Segmentation fault.
0x00007ffff5694052 in ?? () from /usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so
I think this is because of GL_ARB_bindless_texture functionality. Without this option example works fine. Does this bug occurs because of my amd drivers?
sudo lshw -c video
*-display
description: VGA compatible controller
product: Picasso/Raven 2 [Radeon Vega Series / Radeon Vega Mobile Series]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
physical id: 0
bus info: pci@0000:04:00.0
logical name: /dev/fb0
version: c2
width: 64 bits
clock: 33MHz
capabilities: pm pciexpress msi msix vga_controller bus_master cap_list rom fb
configuration: depth=32 driver=amdgpu latency=0 resolution=1920,1080
resources: irq:43 memory:b0000000-bfffffff memory:c0000000-c01fffff ioport:1000(size=256) memory:c0600000-c067ffff memory:c0000-dffff
I can't find list of supported opengl functions for my drivers..
Related: https://github.com/Immediate-Mode-UI/Nuklear/issues/190 - sounds like the same or similar case.
I am no expert on OpenGL so I would need to spend some more time educating myself about the details. Currently I am out of time, but perhaps someone more knowledgeable will chime in :wink:.
Probably a driver issue, doing the same on Linux (6.4.6) with an Nvidia card (RTX 2080), the program runs without any issue.
With Nvidia, there is nvidia-settings which gives detailed information about the device :

Isn't there a similar tool with AMD?
@riri glxinfo shows the GLX settings for AMD. GLX_ARB... and other functions are there. Although, I have the same problem as mentioned above.
I'm getting these errors:
-> [ glfw_opengl4 ] :: make
rm -f bin/demo
cc main.c -std=c89 -Wall -Wextra -pedantic -O2 -o bin/demo -lglfw -lGL -lm -lGLU -lGLEW
In file included from main.c:66:
../../demo/common/overview.c: In function ‘overview’:
../../demo/common/overview.c:15:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
15 | static nk_bool disable_widgets = nk_false;
| ^~~~~~
-> [ glfw_opengl4 ] :: cd bin
-> [ bin ] :: ls
demo*
-> [ bin ] :: ./demo
[GL]: failed to compile shader: 0:2(12): error: extension `GL_ARB_bindless_texture' unsupported in vertex shader
[GL]: failed to compile shader: 0:2(12): error: extension `GL_ARB_bindless_texture' unsupported in fragment shader
demo: nuklear_glfw_gl4.h:179: nk_glfw3_device_create: Assertion `status == GL_TRUE' failed.
zsh: IOT instruction (core dumped) ./demo
-> [ bin ] ::
Getting the same error, Manjaro Linux, GLFW 3.3, and glxinfo shows:
...
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Intel (0x8086)
Device: Mesa Intel(R) HD Graphics 4400 (HSW GT2) (0xa16)
Version: 23.3.3
Accelerated: yes
...
I've added -g to CFLAGS, this is my output:
$ make
rm -f bin/demo
cc main.c -std=c89 -Wall -Wextra -pedantic -O2 -g -o bin/demo -lglfw -lGL -lm -lGLU -lGLEW
In file included from main.c:66:
../../demo/common/overview.c: In function ‘overview’:
../../demo/common/overview.c:15:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
15 | static nk_bool disable_widgets = nk_false;
| ^~~~~~
$ ./bin/demo
[GL]: failed to compile shader: 0:2(12): error: extension `GL_ARB_bindless_texture' unsupported in vertex shader
[GL]: failed to compile shader: 0:2(12): error: extension `GL_ARB_bindless_texture' unsupported in fragment shader
demo: nuklear_glfw_gl4.h:179: nk_glfw3_device_create: Assertion `status == GL_TRUE' failed.
Aborted (core dumped)
$ gdb ./bin/demo core.97291
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bin/demo...
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file /memfd:xshmfence (deleted) during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
warning: Can't open file anon_inode:i915.gem which was expanded to anon_inode:i915.gem during file-backed mapping note processing
[New LWP 97291]
[New LWP 97293]
[New LWP 97292]
This GDB supports auto-downloading debuginfo from the following URLs:
<https://debuginfod.archlinux.org>
Enable debuginfod for this session? (y or [n]) n
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `./bin/demo'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f3e0c90483c in ?? () from /usr/lib/libc.so.6
[Current thread is 1 (Thread 0x7f3e0c32b740 (LWP 97291))]
(gdb) bt
#0 0x00007f3e0c90483c in ?? () from /usr/lib/libc.so.6
#1 0x00007f3e0c8b4668 in raise () from /usr/lib/libc.so.6
#2 0x00007f3e0c89c4b8 in abort () from /usr/lib/libc.so.6
#3 0x00007f3e0c89c3dc in ?? () from /usr/lib/libc.so.6
#4 0x00007f3e0c8acd26 in __assert_fail () from /usr/lib/libc.so.6
#5 0x000055d7ba37fbfe in nk_glfw3_device_create () at /home/peki/Code/Nuklear/demo/glfw_opengl4/nuklear_glfw_gl4.h:179
#6 0x000055d7ba38053a in nk_glfw3_init (win=<optimized out>, init_state=init_state@entry=NK_GLFW3_INSTALL_CALLBACKS,
max_vertex_buffer=max_vertex_buffer@entry=524288, max_element_buffer=max_element_buffer@entry=131072)
at /home/peki/Code/Nuklear/demo/glfw_opengl4/nuklear_glfw_gl4.h:537
#7 0x000055d7ba33851a in main () at main.c:113
(gdb) quit
Also experiencing this issue on Artix Linux, GLFW 3.4-2, Radeon Vega 64.
This fixed it for me: https://github.com/Immediate-Mode-UI/Nuklear/issues/190#issuecomment-909293525