GTK4OpenGL 3.3 context (original) (raw)

I am currently trying make an game with GTK4 and OpenGL. But I get a “Segmentation fault”. It appers when I try to draw a cube. Could anyone help me fix it. I use C99 and Linux Ubuntu 24.04

That’s my stats:
Vendor : AMD
Renderer: AMD Radeon 660M (radeonsi, rembrandt, LLVM 19.1.1, DRM 3.59, 6.11.0-25-generic)
OpenGL : OpenGL ES 3.2 Mesa 24.2.8-1ubuntu1~24.04.1
GLSL : OpenGL ES GLSL ES 3.20

ebassi (Emmanuele Bassi) May 9, 2025, 12:38pm 2

You’ll need to run your code under GDB, and install all debug packages from your distribution.

Comical78 (Comical) May 9, 2025, 12:54pm 3

There’s not other way for doing that? Like I need it for release.

ebassi (Emmanuele Bassi) May 9, 2025, 1:01pm 4

That’s the only way to know what “Segmentation fault” means. Nobody else can do that, because we don’t have access to your computer.

Comical78 (Comical) May 9, 2025, 1:22pm 5

lemme test.

that’s the output.
[New Thread 0x7ffff53ff6c0 (LWP 58011)]
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstvideo-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgsttag-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstpbutils-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstallocators-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstbase-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libgstaudio-1.0.so.0
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libcap.so.2
warning: could not find ‘.gnu_debugaltlink’ file for /lib/x86_64-linux-gnu/libtinfo.so.6
[New Thread 0x7fffe39ff6c0 (LWP 58019)]
[New Thread 0x7fffe31fe6c0 (LWP 58020)]
[New Thread 0x7fffe29fd6c0 (LWP 58021)]
[New Thread 0x7fffe21fc6c0 (LWP 58022)]
[New Thread 0x7fffe15fb6c0 (LWP 58023)]
[New Thread 0x7fffe0dfa6c0 (LWP 58024)]
[New Thread 0x7fffcbfff6c0 (LWP 58025)]
[New Thread 0x7fffcb7fe6c0 (LWP 58026)]
[New Thread 0x7fffcaffd6c0 (LWP 58027)]
[New Thread 0x7fffca7fc6c0 (LWP 58028)]
[New Thread 0x7fffc9ffb6c0 (LWP 58029)]
[New Thread 0x7fffc97fa6c0 (LWP 58030)]
warning: could not find ‘.gnu_debugaltlink’ file for /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so
warning: could not find ‘.gnu_debugaltlink’ file for /usr/lib/x86_64-linux-gnu/gvfs/libgvfscommon.so
[New Thread 0x7fffc8ff96c0 (LWP 58031)]

(process:57997): GLib-GObject-CRITICAL **: 16:21:40.438: …/…/…/gobject/gsignal.c:2533: signal ‘size-allocate’ is invalid for instance ‘0x555555887730’ of type ‘GtkWindow’
[New Thread 0x7fffa7fff6c0 (LWP 58032)]
[New Thread 0x7fffa6fff6c0 (LWP 58033)]
[New Thread 0x7fffa67fe6c0 (LWP 58034)]
[New Thread 0x7fffa5ffd6c0 (LWP 58035)]
[New Thread 0x7fffa57fc6c0 (LWP 58036)]
[New Thread 0x7fffa4ffb6c0 (LWP 58037)]
[New Thread 0x7fff8ffff6c0 (LWP 58038)]
[New Thread 0x7fff8f7fe6c0 (LWP 58039)]
Vendor : AMD
Renderer: AMD Radeon 660M (radeonsi, rembrandt, LLVM 19.1.1, DRM 3.59, 6.11.0-25-generic)
OpenGL : OpenGL ES 3.2 Mesa 24.2.8-1ubuntu1~24.04.1
GLSL : OpenGL ES GLSL ES 3.20

Thread 1 “cubical” received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb)

tragivictoria (Victoria 🏳️‍⚧️🏳️‍🌈) May 9, 2025, 2:31pm 6

Comical78 (Comical) May 9, 2025, 4:55pm 7

(gdb) bt
#0  0x0000000000000000 in ??? ()
#1  0x00006396294ceb79 in setup_cube_buffers () at /media/comical/Work/Projects/blockman/source/core/Model/Cube.c:37
#2  0x00006396294cf12e in on_render (context=<optimized out>, data=<optimized out>, area=0x639665b2c630 [GtkGLArea])
    at /media/comical/Work/Projects/blockman/source/core/Unit/Cubical.c:29
#3  on_render (area=0x639665b2c630 [GtkGLArea], context=<optimized out>, data=<optimized out>)
    at /media/comical/Work/Projects/blockman/source/core/Unit/Cubical.c:12
#4  0x0000773968e02375 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#8  0x000077396957d883 in <emit signal '???' on instance 0x639665b2c630 [GtkGLArea]>
    (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../../../gobject/gsignal.c:3583
    #5  0x000077396957d6bd in _g_closure_invoke_va
    (param_types=0x639665b57a00, n_params=<optimized out>, args=0x7ffce1b226e0, instance=0x639665b2c630, return_value=0x7ffce1b225f0, closure=0x639665b328c0) at ../../../gobject/gclosure.c:897
--Type <RET> for more, q to quit, c to continue without paging--
    #6  signal_emit_valist_unlocked
    (instance=instance@entry=0x639665b2c630, signal_id=signal_id@entry=113, detail=detail@entry=0, var_args=var_args@entry=0x7ffce1b226e0)
    at ../../../gobject/gsignal.c:3424
    #7  0x000077396957d7c1 in g_signal_emit_valist (instance=0x639665b2c630, signal_id=113, detail=0, var_args=var_args@entry=0x7ffce1b226e0)
    at ../../../gobject/gsignal.c:3263
#9  0x0000773968b6a743 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#10 0x0000773968c9f6f4 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#11 0x0000773968c9fcd0 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#12 0x0000773968ca0492 in gtk_widget_snapshot_child () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#13 0x0000773968c8782e in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#14 0x0000773968c9fb0c in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#15 0x0000773968c9fcd0 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
--Type <RET> for more, q to quit, c to continue without paging--
#16 0x0000773968ca035b in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#17 0x0000773968ca1529 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#18 0x0000773968e02237 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#22 0x000077396957d883 in <emit signal '???' on instance 0x6396659c1260 [GdkX11Toplevel]>
    (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../../../gobject/gsignal.c:3583
    #19 0x000077396957d6bd in _g_closure_invoke_va
    (param_types=0x639665863d20, n_params=<optimized out>, args=0x7ffce1b22fe0, instance=0x6396659c1260, return_value=0x7ffce1b22ef0, closure=0x639665b25c80) at ../../../gobject/gclosure.c:897
    #20 signal_emit_valist_unlocked
    (instance=instance@entry=0x6396659c1260, signal_id=signal_id@entry=19, detail=detail@entry=0, var_args=var_args@entry=0x7ffce1b22fe0)
    at ../../../gobject/gsignal.c:3424
    #21 0x000077396957d7c1 in g_signal_emit_valist (instance=0x6396659c1260, signal_id=19, detail=0, var_args=var_args@entry=0x7ffce1b22fe0)
--Type <RET> for more, q to quit, c to continue without paging--
    at ../../../gobject/gsignal.c:3263
#23 0x0000773968e90fd9 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#27 0x000077396957d883 in <emit signal '???' on instance 0x6396659c1730 [GdkFrameClockIdle]>
    (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../../../gobject/gsignal.c:3583
    #24 0x000077396957d6bd in _g_closure_invoke_va
    (param_types=0x0, n_params=<optimized out>, args=0x7ffce1b23320, instance=0x6396659c1730, return_value=0x0, closure=0x6396659c1970)
    at ../../../gobject/gclosure.c:897
    #25 signal_emit_valist_unlocked
    (instance=instance@entry=0x6396659c1730, signal_id=signal_id@entry=28, detail=detail@entry=0, var_args=var_args@entry=0x7ffce1b23320)
    at ../../../gobject/gsignal.c:3424
    #26 0x000077396957d7c1 in g_signal_emit_valist (instance=0x6396659c1730, signal_id=28, detail=0, var_args=var_args@entry=0x7ffce1b23320)
    at ../../../gobject/gsignal.c:3263
--Type <RET> for more, q to quit, c to continue without paging--
#28 0x0000773968e749c3 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#29 0x0000773968745522 in g_timeout_dispatch (source=source@entry=0x639665c2c6d0, callback=<optimized out>, user_data=<optimized out>)
    at ../../../glib/gmain.c:4989
#30 0x000077396874448e in g_main_dispatch (context=0x639665861920) at ../../../glib/gmain.c:3344
#31 0x00007739687a3717 in g_main_context_dispatch_unlocked (context=0x639665861920) at ../../../glib/gmain.c:4152
#32 g_main_context_iterate_unlocked.isra.0 (context=0x639665861920, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
    at ../../../glib/gmain.c:4217
#33 0x0000773968744f77 in g_main_loop_run (loop=0x639665b36860) at ../../../glib/gmain.c:4419
#34 0x00006396294cea34 in CubicalCore () at /media/comical/Work/Projects/blockman/source/core/Unit/Cubical.c:49
#35 main () at /media/comical/Work/Projects/blockman/source/core/App.c:17

two May 29, 2025, 8:42pm 8

you have a lot of “???”, that means it doesn’t find debug files

if you’re on debian, you need to do export DEBUGINFOD_URLS="https://debuginfod.debian.net" before gdb, for other distros you can find the address on https://sourceware.org/elfutils/Debuginfod.html