nomad-software / tkd

GUI toolkit for the D programming language based on Tcl/Tk
MIT License
117 stars 16 forks source link

Crash when running example on OSX Mavericks #13

Closed dymk closed 10 years ago

dymk commented 10 years ago

Here's a log of the commands to build/run the example (just dub --config=example)

[dymk@Codeinator tkd]» dub --config=example
The following changes will be performed:
Fetch x11 >=1.0.0, userWide
Fetch tcltk >=8.6.2, userWide
Fetching x11 1.0.0...
Placing x11 1.0.0 to /Users/dymk/.dub/packages/...
Fetching tcltk 8.6.2...
Placing tcltk 8.6.2 to /Users/dymk/.dub/packages/...
x11: ["x11"]
tcltk: ["tcltk", "x11"]
tkd: ["tkd", "tcltk", "x11"]
Building x11 configuration "tcltk-import", build type debug.
Running dmd...
Building tcltk configuration "library", build type debug.
Running dmd...
Building tkd configuration "example", build type debug.
Compiling...
Linking...
Running ./example
2014-05-08 07:43:59.111 example[1512:507] *** Assertion failure in -[NSBitmapImageRep initWithCGImage:], /SourceCache/AppKit/AppKit-1265.19/AppKit.subproj/NSBitmapImageRep.m:1286
2014-05-08 07:43:59.128 example[1512:507] An uncaught exception was raised
2014-05-08 07:43:59.129 example[1512:507] Invalid parameter not satisfying: cgImage != NULL
2014-05-08 07:43:59.130 example[1512:507] (
    0   CoreFoundation                      0x00007fff90af125c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff91951e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff90af1038 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff8f37ed41 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   AppKit                              0x00007fff8cdb6367 -[NSBitmapImageRep initWithCGImage:] + 135
    5   Tk                                  0x000000010274dcea TkPutImage + 1733
    6   Tk                                  0x000000010274dc49 TkPutImage + 1572
    7   Tk                                  0x0000000102755922 TkMacOSXClearMenubarActive + 3065
    8   Tk                                  0x00000001026defad TkSetWindowMenuBar + 5819
    9   Tk                                  0x00000001026deab7 TkSetWindowMenuBar + 4549
    10  Tk                                  0x00000001026e00eb TkSetWindowMenuBar + 10233
    11  Tk                                  0x00000001026df82c TkSetWindowMenuBar + 7994
    12  Tcl                                 0x00000001025cbab6 Tcl_ListMathFuncs + 1503
    13  Tcl                                 0x00000001025ccd9d Tcl_EvalEx + 1838
    14  Tcl                                 0x00000001025cc689 Tcl_EvalEx + 26
    15  example                             0x00000001021ce442 D3tkd11interpreter3tcl3Tcl33__T4evalTAyaTAyaTAyaTAyaTAyaTAyaZ4evalMFAyaAyaAyaAyaAyaAyaAyaZv + 230
    16  example                             0x0000000102202c25 D3tkd6widget4menu4menu4Menu41__T8addEntryTC3tkd6widget4menu4menu4MenuZ8addEntryMFC3tkd5image5image5ImageAyaDFS3tkd7element7element11CommandArgsZvAyaAyaZC3tkd6widget4menu4menu4Menu + 233
    17  example                             0x0000000102181296 D4main11Application10createMenuMFZv + 258
    18  example                             0x00000001021861ea D4main11Application13initInterfaceMFZv + 222
    19  example                             0x00000001021cfcd4 D3tkd14tkdapplication14TkdApplication6__ctorMFZC3tkd14tkdapplication14TkdApplication + 48
    20  example                             0x0000000102186779 D4main11Application6__ctorMFZC4main11Application + 21
    21  example                             0x000000010217ebd8 _Dmain + 40
    22  example                             0x000000010221e6b9 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv9__lambda1MFZv + 33
    23  example                             0x000000010221e605 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv + 45
    24  example                             0x000000010221e665 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv + 45
    25  example                             0x000000010221e605 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv + 45
    26  example                             0x000000010221e581 _d_run_main + 449
    27  example                             0x000000010217ec32 main + 34
    28  libdyld.dylib                       0x00007fff8d8bb5fd start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
2014-05-08 07:43:59.131 example[1512:507] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: cgImage != NULL'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff90af125c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff91951e75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff90af1038 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff8f37ed41 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   AppKit                              0x00007fff8cdb6367 -[NSBitmapImageRep initWithCGImage:] + 135
    5   Tk                                  0x000000010274dcea TkPutImage + 1733
    6   Tk                                  0x000000010274dc49 TkPutImage + 1572
    7   Tk                                  0x0000000102755922 TkMacOSXClearMenubarActive + 3065
    8   Tk                                  0x00000001026defad TkSetWindowMenuBar + 5819
    9   Tk                                  0x00000001026deab7 TkSetWindowMenuBar + 4549
    10  Tk                                  0x00000001026e00eb TkSetWindowMenuBar + 10233
    11  Tk                                  0x00000001026df82c TkSetWindowMenuBar + 7994
    12  Tcl                                 0x00000001025cbab6 Tcl_ListMathFuncs + 1503
    13  Tcl                                 0x00000001025ccd9d Tcl_EvalEx + 1838
    14  Tcl                                 0x00000001025cc689 Tcl_EvalEx + 26
    15  example                             0x00000001021ce442 D3tkd11interpreter3tcl3Tcl33__T4evalTAyaTAyaTAyaTAyaTAyaTAyaZ4evalMFAyaAyaAyaAyaAyaAyaAyaZv + 230
    16  example                             0x0000000102202c25 D3tkd6widget4menu4menu4Menu41__T8addEntryTC3tkd6widget4menu4menu4MenuZ8addEntryMFC3tkd5image5image5ImageAyaDFS3tkd7element7element11CommandArgsZvAyaAyaZC3tkd6widget4menu4menu4Menu + 233
    17  example                             0x0000000102181296 D4main11Application10createMenuMFZv + 258
    18  example                             0x00000001021861ea D4main11Application13initInterfaceMFZv + 222
    19  example                             0x00000001021cfcd4 D3tkd14tkdapplication14TkdApplication6__ctorMFZC3tkd14tkdapplication14TkdApplication + 48
    20  example                             0x0000000102186779 D4main11Application6__ctorMFZC4main11Application + 21
    21  example                             0x000000010217ebd8 _Dmain + 40
    22  example                             0x000000010221e6b9 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv9__lambda1MFZv + 33
    23  example                             0x000000010221e605 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv + 45
    24  example                             0x000000010221e665 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv + 45
    25  example                             0x000000010221e605 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv + 45
    26  example                             0x000000010221e581 _d_run_main + 449
    27  example                             0x000000010217ec32 main + 34
    28  libdyld.dylib                       0x00007fff8d8bb5fd start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Error executing command run: Program exited with code -6
nomad-software commented 10 years ago

There are a few things to check.

dymk commented 10 years ago

DMD is 2.065, dub is ~master, port reports tk as version tk @8.6.1_1+quartz

I don't get a crash, however, when commenting out lines 167 - 171 in example.d:

        auto fileMenu = new Menu(menuBar, "File", 0)
            .addEntry(new EmbeddedPng!("cancel.png"), "Quit", &this.exitApplication, ImagePosition.left, "Ctrl-Q");

        auto helpMenu = new Menu(menuBar, "Help", 0)
            .addEntry(new EmbeddedPng!("help.png"), "About...", &this.showAbout, ImagePosition.left, "F1");

It's probably the EmbeddedPng interacting strangely with the menu bar. No other image buttons show up with an image either, but rather only as a normal OSX buttons.

nomad-software commented 10 years ago

Even though you have Tcl/Tk 8.6 installed make sure that's the one that's being linked to the executable. Check the dependencies on the compiled exe by using otool in the terminal. (you may need to install the xcode command line tools)

otool -L <executable>

http://tech-queries.blogspot.co.uk/2011/04/dynamic-library-dependency-on-mac-os-x.html

dymk commented 10 years ago

Oh good catch!

[dymk@Codeinator tkd]» otool -L build/example/example
build/example/example:
    /System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.9)
    /System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.9)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

I'll start fiddling around with getting OSX to use the ports version instead of the preinstalled one. If you know an easy way to do this, please let me know.

nomad-software commented 10 years ago

Closing this as it was due to linking against an unsupported version of Tcl/Tk.