Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
8.89k stars 534 forks source link

glShaderSource causing segmentation fault #368

Open caffeinelucy opened 2 years ago

caffeinelucy commented 2 years ago

I compiled the glfw_opengl4 demo like this: gcc -g --std=c89 -o demo main.c -lglfw -lGL -lGLEW -lm I'm running debian using mesa. opengl 4.6 is available and working. valgrind showed "Address 0x0 is not stack'd, malloc'd or (recently) free'd" for nuklear_glfw_gl4.h line 156. I added some code to check for gl errors and to verify dev->frag_shdr is set, everything seems fine. Since I couldn't find an existing issue regarding this mysterious segmentation fault, did anyone else encounter (and maybe solve) it?

kiner-shah commented 2 years ago

Since you are running on Linux (Debian) and getting a Segmentation fault, you can use a debugger like GDB to see the back trace for the crash. Check if there is a core dump file generated (filename should have prefix "core"). If not, try the below:

ulimit -c unlimited
./demo

If now a core file is generated, and if you have GDB installed, then run:

gdb ./demo core

GDB terminal should open and you can use bt command (for back trace) so see all the stack frames. It should show exactly which line caused the crash.

Copy and paste that output here so that it can be fixed or if you fix it yourself, you can submit a pull request here.