* Re: Segfault when building GTK+ application with Meson
@ 2021-03-14 15:41 HiPhish
0 siblings, 0 replies; 2+ messages in thread
From: HiPhish @ 2021-03-14 15:41 UTC (permalink / raw)
To: help-guix
I have tried running the application through GDB to print a backtrace, and
here is what it prints:
$ gdb ./build/src/vala-language-server
GNU gdb (GDB) 10.1
(gdb) run
Starting program: /home/hiphish/Applications/lsp/vala-language-server/build/
src/vala-language-server
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-
glibc-2.31/lib/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fe1f2c in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7fffffffdd28,
env=env@entry=0x7fffffffdd38) at dl-init.c:74
74 dl-init.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7fe1f2c in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7fffffffdd28,
env=env@entry=0x7fffffffdd38) at dl-init.c:74
#1 0x00007ffff7fe20a1 in call_init (env=0x7fffffffdd38, argv=0x7fffffffdd28, argc=1,
l=<optimized out>) at dl-init.c:37
#2 _dl_init (main_map=0x7ffff7ffe1a0, argc=1, argv=0x7fffffffdd28, env=0x7fffffffdd38)
at dl-init.c:88
#3 0x00007ffff7fd308a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#4 0x0000000000000001 in ?? ()
#5 0x00007fffffffe10e in ?? ()
#6 0x0000000000000000 in ?? ()
To me it looks like even before the segmentation fault happens even before the
main function has been called, and it happens in a system library. Is there a
dependency I am missing? I still don't understand why the program only crashes
if I compile it myself with dependencies from Guix, but not if I install the
application itself through Guix.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Segfault when building GTK+ application with Meson
@ 2021-03-12 20:21 HiPhish
0 siblings, 0 replies; 2+ messages in thread
From: HiPhish @ 2021-03-12 20:21 UTC (permalink / raw)
To: help-guix
[-- Attachment #1: Type: text/plain, Size: 2820 bytes --]
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:
(specifications->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
segfault:
#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);
puts("Hello");
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
hello
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/
fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/libthread_db.so.1".
Core was generated by `./demo'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fe962f75f2c in call_init (l=<optimized out>, argc=argc@entry=1,
argv=argv@entry=0x7ffdd0e22cf8,
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
rules).
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.
[1]: https://mesonbuild.com/Tutorial.html
[-- Attachment #2: main.c --]
[-- Type: text/x-csrc, Size: 745 bytes --]
#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);
/* label = gtk_label_new("Hello GNOME!"); */
/* gtk_container_add(GTK_CONTAINER(window), label); */
/* gtk_window_set_title(GTK_WINDOW(window), "Welcome to GNOME"); */
/* gtk_widget_show_all(window); */
}
int main(int argc, char **argv) {
GtkApplication *app;
int status;
app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE);
puts("Hello");
/* g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); */
/* status = g_application_run(G_APPLICATION(app), argc, argv); */
/* g_object_unref(app); */
/* return status; */
return 0;
}
[-- Attachment #3: meson.build --]
[-- Type: text/x-meson, Size: 170 bytes --]
project('tutorial', 'c')
gtkdep = dependency('gtk+-3.0')
glibdep = [dependency('glib-2.0'), dependency('gobject-2.0')]
executable('demo', 'main.c', dependencies: gtkdep)
[-- Attachment #4: guix.scm --]
[-- Type: text/x-scheme, Size: 129 bytes --]
;;; Manifest file for GNU Guix environment
(specifications->manifest
'("gcc-toolchain" "meson" "ninja" "pkg-config" "gtk+@3"))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-14 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-14 15:41 Segfault when building GTK+ application with Meson HiPhish
-- strict thread matches above, loose matches on Subject: below --
2021-03-12 20:21 HiPhish
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).