[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segfault when building GTK+ application with Meson

From: HiPhish
Subject: Segfault when building GTK+ application with Meson
Date: Fri, 12 Mar 2021 21:21:39 +0100

Hello everyone,

I have a weird problem: when I create a Guix environment for GTK+ development 
and when I use Meson to build the project I get a segmentation fault when I 
run the compiled application. I have tried with a basic C example from Meson's 
website[1]. Here is the environment manifest:

      '("gcc-toolchain" "meson" "ninja" "pkg-config" "gtk+@3"))

I enable it as usual: `guix environment -m guix.scm`. Then I compile it with 
Meson as usual and run it:

    $ meson build
    $ cd build
    $ meson compile
    $ ./demo
    Segmentation fault

The C code, stripped down to the base basic of what it takes to trigger as 

    #include <gtk/gtk.h>
    #include <stdio.h>
    static void activate(GtkApplication *app, gpointer user_data) {
        GtkWidget *window;
        GtkWidget *label;
        window = gtk_application_window_new(app);  /* <--- Note this */
    int main(int argc, char **argv) {
        GtkApplication *app;
        app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE);
        return 0;

If I remove the marked line above the application terminates normally. 
However, if I compile the above code with GCC it works fine:

    $ gcc $(pkg-config --cflags --libs gtk+-3.0) main.c

Loading the segfault into GDB reveals the following:

    $ gdb ./demo core.32123
    GNU gdb (GDB) 10.1
    Reading symbols from ./demo...
    [New LWP 32123]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/gnu/store/
    Core was generated by `./demo'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x00007fe962f75f2c in call_init (l=<optimized out>, argc=argc@entry=1, 
        env=env@entry=0x7ffdd0e22d08) at dl-init.c:74
    74      dl-init.c: No such file or directory.

It would be really nice if you could help me track down the issue because it 
affects more than just GTK+, but I have not been able to narrow its source down 
any further. I have attached the source code (I hope that's OK with the 

To provide some background: I want to get into GTK+ development and Vala, so I 
tried running the Vala language server. It has a bug which has been fixed in 
the current master branch, so I tried compiling from source, but I get a 
segmentation fault there as well. The only dependencies GTK+ 3 and the Vala 
language server have in common are glib and json-glib, so my guess is that's 
it's something inside glib. The language server does not segfault if I let 
Guix build it, only if I use Guix to set up an environment and then compile it 
from source myself.


Attachment: main.c
Description: Text Data

Description: Text Data

Attachment: guix.scm
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]