Repository navigation
MacOS tips
Iñaki edited this page Aug 6, 2020
·
2 revisions
If you try to run gi-gtk code in recent versions of MacOS under the ghci interpreter, you might encounter an error like the following:
santi~/haskell_exploit/Exploit/src$ stack runghc Main.hs
2019-07-28 10:02:37.957 ghc[51071:1657595] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff4aadbcfd __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff75185a17 objc_exception_throw + 48
2 CoreFoundation 0x00007fff4aaf585d -[NSException raise] + 9
3 AppKit 0x00007fff4812a7ae -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 317
4 AppKit 0x00007fff48127bdb -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1479
5 AppKit 0x00007fff4812760e -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
6 AppKit 0x00007fff483f3f08 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
7 libgdk-3.0.dylib 0x00000001152aacb0 -[GdkQuartzNSWindow initWithContentRect:styleMask:backing:defer:screen:] + 64
8 libgdk-3.0.dylib 0x00000001152b7d1e _gdk_quartz_display_create_window_impl + 1454
9 libgdk-3.0.dylib 0x0000000115294008 gdk_window_new + 952
10 libgtk-3.0.dylib 0x000000011923b27a gtk_window_realize + 1242
11 libgtk-3.0.dylib 0x0000000118f384aa gtk_application_window_real_realize + 186
12 libgobject-2.0.0.dylib 0x000000010d67d6f6 _g_closure_invoke_va + 214
13 libgobject-2.0.0.dylib 0x000000010d6942b8 g_signal_emit_valist + 1352
14 libgobject-2.0.0.dylib 0x000000010d694d32 g_signal_emit + 130
15 libgtk-3.0.dylib 0x00000001192159d3 gtk_widget_realize + 291
16 libgtk-3.0.dylib 0x000000011923a6c3 gtk_window_show + 211
17 libgobject-2.0.0.dylib 0x000000010d67d4fd g_closure_invoke + 189
18 libgobject-2.0.0.dylib 0x000000010d693624 signal_emit_unlocked_R + 1316
19 libgobject-2.0.0.dylib 0x000000010d6946b1 g_signal_emit_valist + 2369
20 libgobject-2.0.0.dylib 0x000000010d694d32 g_signal_emit + 130
21 libgtk-3.0.dylib 0x0000000119215197 gtk_widget_show + 359
22 libHSgi-gtk-3.0.30-6QmVefkNP3Q8GQ3yTLidxY-ghc8.6.5.dylib 0x0000000116a1953c sFK6L_info + 132
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
This problem is due to some extra checks done in recent versions of MacOS, and is discussed in issue #243. A workaround is to pass the flag -fno-ghci-sandbox to ghci, which can be conveniently done by adding to .ghci the following:
:cmd pure $ if System.Info.os == "darwin" then ":set -fno-ghci-sandbox" else ""
Thanks to @deech and @ArturGajowy for the tip!