Skip to content

Linking GTK3 (On Linux) in a WebUI Zig project causes instant segfault on program startup. #111

@jarcopolo

Description

@jarcopolo

OS: I tested it both on Fedora 43 and Arch Linux
Zig version 0.14.1

I wanted to add OS file picker dialogs to my project and to do that, I tried using nfd-zig and osdialog-zig.
However, when importing any of these libraries, I get instant segfault on program startup, like this:

/usr/bin/zig build run
Segmentation fault at address 0x7f1182249b28
???:?:?: 0x7f1182249b28 in ??? (???)
Unwind error at address `libwebui.so:0x7f1182249b28` (error.AddressOutOfRange), trace may be incomplete

???:?:?: 0x7f1181789aa6 in ??? (libgtk-3.so.0)
???:?:?: 0x7f1181efddaf in ??? (libglib-2.0.so.0)
???:?:?: 0x7f1181785bf8 in ??? (libgtk-3.so.0)
???:?:?: 0x7f1181789821 in ??? (libgtk-3.so.0)
/home/wilson2/.cache/zig/p/nfdzig-0.1.0-11fxvN6IBgD5rvvfjrw1wPqibMsbUJ-h2ZcGR6FOEvrm/nativefiledialog/src/nfd_gtk.c:175:11: 0x1037ff2 in NFD_OpenDialog (/home/wilson2/.cache/zig/p/nfdzig-0.1.0-11fxvN6IBgD5rvvfjrw1wPqibMsbUJ-h2ZcGR6FOEvrm/nativefiledialog/src/nfd_gtk.c)
    if ( !gtk_init_check( NULL, NULL ) )
          ^
/home/wilson2/.cache/zig/p/nfdzig-0.1.0-11fxvN6IBgD5rvvfjrw1wPqibMsbUJ-h2ZcGR6FOEvrm/src/lib.zig:25:36: 0x10e6f99 in openFileDialog (webui_gtk_crash_demo)
    const result = c.NFD_OpenDialog(if (filter != null) filter.? else null, if (default_path != null) default_path.? else null, &out_path);
                                   ^
/home/wilson2/Documents/Coding/Zig/webui-gtk-crash-demo/src/main.zig:6:27: 0x10e6e38 in main (webui_gtk_crash_demo)
    if (nfd.openFileDialog(null, null)) |path_opt|
                          ^
/usr/lib/zig/std/start.zig:660:37: 0x10e7812 in main (webui_gtk_crash_demo)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7f118140f5b4 in ??? (libc.so.6)
???:?:?: 0x7f118140f667 in ??? (libc.so.6)
???:?:?: 0x1037114 in ??? (???)
run
└─ run webui_gtk_crash_demo failure

I created a repo with minimal reproduction examples, so that you can check it:
https://github.com/jarcopolo/webui-gtk-crash-demo

Apart from that, thanks for your work on the project, on Windows everything works alright.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions