Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtk3: segfault on Darwin #23946

Closed
jbaum98 opened this issue Mar 16, 2017 · 3 comments
Closed

gtk3: segfault on Darwin #23946

jbaum98 opened this issue Mar 16, 2017 · 3 comments
Labels
6.topic: darwin Running or building packages on Darwin

Comments

@jbaum98
Copy link
Contributor

jbaum98 commented Mar 16, 2017

Issue description

All programs that link to gtk+3 segfault when executed. This doesn't happen when the executable is linked to other non-nixpkgs versions of the gtk+3 library.

Steps to reproduce

// example.c
#include <gtk/gtk.h>

static void activate (GtkApplication* app, gpointer user_data) {
    GtkWidget *window;

    window = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (window), "Window");
    gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
    gtk_widget_show_all (window);
}

int main (int argc, char **argv) {
    GtkApplication *app;
    int status;

    app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
    g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
    status = g_application_run (G_APPLICATION (app), argc, argv);
    g_object_unref (app);

    return status;
}
# Makefile
example: example.c
	clang `pkg-config --cflags gtk+-3.0` -o $@ $< `pkg-config --libs gtk+-3.0`

install: example
	mkdir -p $(out)
	cp example $(out)
{ nixpkgs ? import <nixpkgs> {} }:
let
  inherit (nixpkgs.pkgs) gtk3;
  inherit (nixpkgs.pkgs) pkgconfig;
  inherit (nixpkgs) stdenv;
in
stdenv.mkDerivation {
  name = "gtk-test";
  src = ./.;

  buildInputs = [ gtk3 pkgconfig ];
}

Building it with just make using pkg-config and gtk+3 from Homebrew, the compiled executable runs and produces a blank window. Building with nix-build and running the compiled executable produces a segfault with the following backtrace.

* thread #1: tid = 0x10f3035, 0x00007fff8fe39dd6 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff8fe39dd6 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff8ff25787 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fff8fd9f420 libsystem_c.dylib`abort + 129
    frame #3: 0x00007fff8fe99f21 libsystem_malloc.dylib`szone_error + 626
    frame #4: 0x000000010121b162 CoreFoundation`__CFBasicHashRehash + 3154
    frame #5: 0x000000010121d7f5 CoreFoundation`__CFBasicHashAddValue + 85
    frame #6: 0x000000010121b31b CoreFoundation`CFBasicHashAddValue + 315
    frame #7: 0x000000010124d7bd CoreFoundation`CFRunLoopAddObserver + 381
    frame #8: 0x00000001006f4fae libgdk-3.0.dylib`_gdk_quartz_event_loop_init + 206
    frame #9: 0x00000001006f2059 libgdk-3.0.dylib`_gdk_quartz_events_init + 9
    frame #10: 0x00000001006f1753 libgdk-3.0.dylib`_gdk_quartz_display_open + 163
    frame #11: 0x00000001006d2167 libgdk-3.0.dylib`gdk_display_manager_open_display + 343
    frame #12: 0x000000010021f7d3 libgtk-3.0.dylib`gtk_init_check + 19
    frame #13: 0x000000010021f84d libgtk-3.0.dylib`gtk_init + 13
    frame #14: 0x000000010010fa80 libgtk-3.0.dylib`gtk_application_startup + 80
    frame #15: 0x0000000100a944c0 libgobject-2.0.0.dylib`g_closure_invoke + 272
    frame #16: 0x0000000100aa965d libgobject-2.0.0.dylib`signal_emit_unlocked_R + 1245
    frame #17: 0x0000000100aaa71d libgobject-2.0.0.dylib`g_signal_emit_valist + 2205
    frame #18: 0x0000000100aaada6 libgobject-2.0.0.dylib`g_signal_emit + 134
    frame #19: 0x000000010097a657 libgio-2.0.0.dylib`g_application_register + 215
    frame #20: 0x000000010097c362 libgio-2.0.0.dylib`g_application_real_local_command_line + 1170
    frame #21: 0x000000010097ac11 libgio-2.0.0.dylib`g_application_run + 337
    frame #22: 0x0000000100000e4d example`main + 93
    frame #23: 0x00007fff8fd0b255 libdyld.dylib`start + 1
    frame #24: 0x00007fff8fd0b255 libdyld.dylib`start + 1

Technical details

  • System: OSX Sierra (10.12.3 (16D32))
  • Nix version: 1.116
  • Nixpkgs version: 17.09pre102933.26625c9
@vcunat vcunat added the 6.topic: darwin Running or building packages on Darwin label Mar 16, 2017
@vbgl
Copy link
Contributor

vbgl commented Mar 16, 2017

You can try to export DYLD_FRAMEWORK_PATH=/System/Library/Frameworks before running the executable. See #12346.

@LnL7
Copy link
Member

LnL7 commented Mar 16, 2017

I'm pretty sure this case is also fixed by #22571, but I run into this now with the example.

(example:55230): Gtk-WARNING **: Locale not supported by C library.
        Using the fallback 'C' locale.
2017-03-16 12:46:15.955 example[55230:2689031] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
Bus error: 10

@jbaum98
Copy link
Contributor Author

jbaum98 commented Mar 16, 2017

Yup this is fixed by #22571. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

No branches or pull requests

4 participants