Debugging Segmentation Fault for D program using LLDB - macos

I'm currently trying to debug a Segmentation Fault: 11 on Mac in an executable produced by the DMD compiler, using LLDB.
The thing is I'm quite lost since I'm not too familiar with debugging tools.
All I do is start lldb with my binary and then execute the command run with the appropriate arguments. When the application crashes, I'm doing a thread backtrace and this is the output I'm getting:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7ffeef3fffd0)
frame #0: 0x00000001003f59e0 arturo`_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl + 8
arturo`_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl:
-> 0x1003f59e0 <+8>: movq %rbx, -0x50(%rbp)
0x1003f59e4 <+12>: movq %r12, -0x48(%rbp)
0x1003f59e8 <+16>: movq %r13, -0x40(%rbp)
0x1003f59ec <+20>: movq %r14, -0x38(%rbp)
Target 0: (arturo) stopped.
(lldb) thread traceback
invalid command 'thread traceback'.
(lldb) thread backtrace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7ffeef3fffd0)
* frame #0: 0x00000001003f59e0 arturo`_D2gc4impl12conservativeQw14ConservativeGC__T9runLockedS_DQCeQCeQCcQCnQBs12mallocNoSyncMFNbmkKmxC8TypeInfoZPvS_DQEgQEgQEeQEp10mallocTimelS_DQFiQFiQFgQFr10numMallocslTmTkTmTxQCzZQFcMFNbKmKkKmKxQDsZQDl + 8
frame #1: 0x00000001003ed77e arturo`_D2gc4impl12conservativeQw14ConservativeGC6qallocMFNbmkxC8TypeInfoZS4core6memory8BlkInfo_ + 122
frame #2: 0x00000001003f87a7 arturo`gc_qalloc + 59
frame #3: 0x00000001003e389f arturo`_D4core6memory2GC6qallocFNaNbmkxC8TypeInfoZSQBqQBo8BlkInfo_ + 43
frame #4: 0x00000001000037f3 arturo`_D3std5array__T8AppenderTAyaZQo13ensureAddableMFmZ9__lambda3MFNaNbNeZS4core6memory8BlkInfo_ + 43
frame #5: 0x000000010000372d arturo`_D3std5array__T8AppenderTAyaZQo13ensureAddableMFNaNbNfmZv + 269
frame #6: 0x00000001001d6a18 arturo`_D3std5array__T8AppenderTAyaZQo__T3putTAxaZQjMFQiZ10bigDataFunMFNaNbNfmZAa + 24
frame #7: 0x00000001001d69b1 arturo`_D3std5array__T8AppenderTAyaZQo__T3putTAxaZQjMFNaNbNfQoZv + 33
frame #8: 0x00000001000057b1 arturo`_D3std6format__T10FormatSpecTaZQp__T17writeUpToNextSpecTSQCd5array__T8AppenderTAyaZQoZQByMFNaNlNfKQBqZb + 121
frame #9: 0x0000000100023ab7 arturo`_D3std6format__T14formattedWriteTSQBg5array__T8AppenderTAyaZQoTaTQjZQCaFNaNfKQBsMxAaQBcZk + 103
frame #10: 0x0000000100023990 arturo`_D3std6format__TQkTaTAyaZQtFNaNfxAaQoZQr + 88
frame #11: 0x00000001001a1b6f arturo`_D5panic14getErrorStringFAyaQdAQgQdZQl + 1199
frame #12: 0x00000001001a2073 arturo`_D5panic31WARN_AssignmentInsideExpression6__ctorMFAyaZCQCbQBy + 227
frame #13: 0x00000001001a8847 arturo`_D6parser9statement9Statement7executeMFPC5value5ValuebZQp + 87
Any idea where to look? Seems like it has something to do with the Garbage Collector, but still not sure. Could it be an out-of-memory error?
Any pointers would be more than welcome!

Related

Xcode 12.1 Debugging EXC_BAD_ACCESS

After updating the App to XCode 12 and iOS 14. I get a frequent crash where it does not show the Application line. Below I've given the backtrace I printed from XCode. Rarely I see the crash line stops at executeFetchRequest. I am not sure if this is related to this. How do I debug this issue and stop the crash happening.
Using Xcode 12.1
Device iPhone XS and iPad Air 2.
(lldb) bt
* thread #12, queue = 'NSManagedObjectContext 0x28185a2f0', stop reason = EXC_BAD_ACCESS (code=1, address=0x2dafa5100)
* frame #0: 0x00000001ba152534 libobjc.A.dylib`object_getIndexedIvars + 28
frame #1: 0x00000001ac0f67a8 CoreData`_PFObjectIDFastHash64 + 36
frame #2: 0x00000001a608e4f8 CoreFoundation`__CFBasicHashRehash + 992
frame #3: 0x00000001a6092414 CoreFoundation`CFBasicHashRemoveValue + 2384
frame #4: 0x00000001a5fa9ec0 CoreFoundation`CFDictionaryRemoveValue + 236
frame #5: 0x00000001ac0431c0 CoreData`-[NSManagedObjectContext(_NSInternalAdditions) _forgetObject:propagateToObjectStore:removeFromRegistry:] + 124
frame #6: 0x00000001ac0226ec CoreData`-[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 860
frame #7: 0x00000001ac140198 CoreData`__90-[NSManagedObjectContext(_NSInternalNotificationHandling) _registerAsyncReferenceCallback]_block_invoke + 72
frame #8: 0x00000001ac136410 CoreData`developerSubmittedBlockToNSManagedObjectContextPerform + 164
frame #9: 0x00000001016a15f0 libdispatch.dylib`_dispatch_client_callout + 20
frame #10: 0x00000001016a8fa8 libdispatch.dylib`_dispatch_lane_serial_drain + 736
frame #11: 0x00000001016a9cb4 libdispatch.dylib`_dispatch_lane_invoke + 448
frame #12: 0x00000001016b5e38 libdispatch.dylib`_dispatch_workloop_worker_thread + 1520
frame #13: 0x00000001edf53908 libsystem_pthread.dylib`_pthread_wqthread + 276

Suave "Hello World!" program doesn't work with visual studio for Mac

I got runtime errors trying to execute the "Hello World!" program from Suave web page:
open Suave.Web
open Suave.Successful
[<EntryPoint>]
let main argv =
startWebServer defaultConfig (OK "Hello, Suave!")
0
With this errors:
Loaded assembly: /Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/bin/Debug/SuaveRestApi.exe
Loaded assembly: /Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/bin/Debug/FSharp.Core.dll
[External] Loaded assembly: /Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/bin/Debug/Suave.dll
[External] Loaded assembly:
/Library/Frameworks/Mono.framework/Versions/5.18.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
[External] Loaded assembly:
/Library/Frameworks/Mono.framework/Versions/5.18.0/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
[External] Method idx 6984 is greater than number of rows (6984) in
PPDB MethodDebugInformation table, for method
.$YoLo:.cctor in
'/Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/bin/Debug/Suave.pdb'.
Likely a malformed PDB file. Stacktrace:
at <0xffffffff> at (wrapper managed-to-native)
object.__icall_wrapper_mono_generic_class_init (intptr) [0x00007] in
<699ddfd029d348d1a69fb1f9fc28d7cb>:0 at YoLo/UTF8.get_utf8 ()
[0x00000] in
/Users/ademar/Projects/release/suave/src/Suave/Utils/YoLo.fs:447 at
Suave.Successful.OK (string) [0x00000] in
/Users/ademar/Projects/release/suave/src/Suave/Combinators.fs:136 at
App.main (string[]) [0x00000] in /Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/App.fs:6
at (wrapper runtime-invoke) .runtime_invoke_int_object
(object,intptr,intptr,intptr) [0x00057] in
<5c0abea33afd9276a7450383a3be0a5c>:0 Memory around native instruction
pointer (0x7fff71ccc23e): 0x7fff71ccc22e ff ff c3 90 90 90 b8 48 01
00 02 49 89 ca 0f 05 .......H...I.... 0x7fff71ccc23e 73 08 48 89 c7
e9 6f a1 ff ff c3 55 48 89 e5 41 s.H...o....UH..A 0x7fff71ccc24e 57
41 56 41 55 41 54 53 48 81 ec 88 00 00 00 49 WAVAUATSH......I
0x7fff71ccc25e 89 f4 48 8d 05 01 c3 cb 32 48 8b 00 48 8d 9d 60
..H.....2H..H..`
Native stacktrace:
0 mono 0x000000010ba29842
mono_dump_native_crash_info + 898 1 mono
0x000000010b9cd303 mono_handle_native_crash + 195 2
libsystem_platform.dylib 0x00007fff71d77b3d _sigtramp + 29
3 mono 0x000000010bcdf008
simple_lower_case_mapping_higharea_table0 + 20296 4
libsystem_c.dylib 0x00007fff71c351c9 abort + 127 5
mono 0x000000010bbf9c5f
mono_log_write_logfile + 351 6 mono
0x000000010bc15dac monoeg_g_log + 204 7 mono
0x000000010bac9e68 mono_ppdb_get_seq_points + 1112 8 mono
0x000000010b93492f mono_method_to_ir + 1151 9 mono
0x000000010b91ade7 mini_method_compile + 3479 10 mono
0x000000010b91e32c mono_jit_compile_method_inner + 76 11 mono
0x000000010b921cc9 mono_jit_compile_method_with_opt + 2665 12 mono
0x000000010b925d8e mono_jit_runtime_invoke + 526 13 mono
0x000000010bb241d4 do_runtime_invoke + 84 14 mono
0x000000010bb201a8 mono_runtime_class_init_full + 872 15 mono
0x000000010b97a69c mono_generic_class_init + 28 16 ???
0x000000010beb7e2c 0x0 + 4494949932 17 mono
0x000000010b9261d3 mono_jit_runtime_invoke + 1619 18 mono
0x000000010bb241d4 do_runtime_invoke + 84 19 mono
0x000000010bb27cac do_exec_main_checked + 156 20 mono
0x000000010b98d19d mono_jit_exec + 349 21 mono
0x000000010b99037f mono_main + 11615 22 mono
0x000000010b915078 main + 264 23 libdyld.dylib
0x00007fff71b8ced9 start + 1 Pkilling 0x70000ed57000 from 0x1115795c0
Pkilling 0x70000eb54000 from 0x1115795c0 Entering thread summarizer
pause from 0x1115795c0 Finished thread summarizer pause from
0x1115795c0.
Waiting for dumping threads to resume
Debug info from gdb:
(lldb) command source -s 0 '/tmp/mono-gdb-commands.UoI26p' Executing
commands in '/tmp/mono-gdb-commands.UoI26p'. (lldb) process attach
--pid 1457 Process 1457 stopped
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00007fff71ccb2d2 libsystem_kernel.dylib__wait4 + 10 libsystem_kernel.dylib__wait4:
-> 0x7fff71ccb2d2 <+10>: jae 0x7fff71ccb2dc ; <+20>
0x7fff71ccb2d4 <+12>: movq %rax, %rdi
0x7fff71ccb2d7 <+15>: jmp 0x7fff71cc6381 ; cerror
0x7fff71ccb2dc <+20>: retq Target 0: (mono) stopped.
Executable module set to
"/Library/Frameworks/Mono.framework/Versions/5.18.0/bin/mono".
Architecture set to: x86_64h-apple-macosx. (lldb) thread list Process
1457 stopped
* thread #1: tid = 0xd6f5, 0x00007fff71ccb2d2 libsystem_kernel.dylib__wait4 + 10, name = 'tid_307', queue =
'com.apple.main-thread', stop reason = signal SIGSTOP thread #2: tid
= 0xd6f6, 0x00007fff71cc97de libsystem_kernel.dylib__psynch_cvwait + 10, name = 'SGen worker' thread #3: tid = 0xd6f8, 0x00007fff71cc61b6
libsystem_kernel.dylibsemaphore_wait_trap + 10, name = 'Finalizer'
thread #4: tid = 0xd6f9, 0x00007fff71cc93e6
libsystem_kernel.dylib__recvfrom + 10, name = 'Debugger agent'
thread #5: tid = 0xd700, 0x00007fff71cc7b6a
libsystem_kernel.dylib__workq_kernreturn + 10 thread #6: tid =
0xd701, 0x00007fff71cc7b6a libsystem_kernel.dylib__workq_kernreturn +
10 (lldb) thread backtrace all
* thread #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP * frame #0: 0x00007fff71ccb2d2
libsystem_kernel.dylib__wait4 + 10
frame #1: 0x000000010ba299b6 monomono_dump_native_crash_info at mini-posix.c:1079 [opt]
frame #2: 0x000000010ba29862 monomono_dump_native_crash_info(signal="SIGABRT",
ctx=0x00007ffee42eb0f0, info=<unavailable>) at mini-posix.c:1102 [opt]
frame #3: 0x000000010b9cd303 monomono_handle_native_crash(signal="SIGABRT",
ctx=0x00007ffee42eb0f0, info=0x00007ffee42eb088) at
mini-exceptions.c:3197 [opt]
frame #4: 0x00007fff71d77b3d libsystem_platform.dylib_sigtramp + 29
frame #5: 0x00007fff71ccc23f libsystem_kernel.dylib__pthread_kill + 11
frame #6: 0x00007fff71d82c1c libsystem_pthread.dylibpthread_kill + 285
frame #7: 0x00007fff71c351c9 libsystem_c.dylibabort + 127
frame #8: 0x000000010bbf9c5f monomono_log_write_logfile(log_domain=<unavailable>,
level=<unavailable>, hdr=<unavailable>, message="Method idx 6984 is
greater than number of rows (6984) in PPDB MethodDebugInformation
table, for method <StartupCode$Suave>.$YoLo:.cctor in
'/Users/[myUserName]/Library/Mobile
Documents/com~apple~CloudDocs/Projects/SuaveRestApi/SuaveRestApi/bin/Debug/Suave.pdb'.
Likely a malformed PDB file.") at mono-log-common.c:135 [opt]
frame #9: 0x000000010bc15dac monomonoeg_g_log [inlined] monoeg_g_logstr(log_domain=0x0000000000000000,
log_level=G_LOG_LEVEL_ERROR, msg=) at goutput.c:117 [opt]
frame #10: 0x000000010bc15d83 monomonoeg_g_log [inlined] monoeg_g_logv_nofree(format=<unavailable>, args=<unavailable>) at
goutput.c:128 [opt]
frame #11: 0x000000010bc15d70 monomonoeg_g_log [inlined] monoeg_g_logv(format=, args=) at
goutput.c:135 [opt]
frame #12: 0x000000010bc15d70 monomonoeg_g_log(log_domain=0x0000000000000000,
log_level=G_LOG_LEVEL_ERROR, format=<unavailable>) at goutput.c:144
[opt]
frame #13: 0x000000010bac9e68 monomono_ppdb_get_seq_points(minfo=,
source_file=, source_file_list=,
source_files=, seq_points=0x00007ffee42eb730,
n_seq_points=) at debug-mono-ppdb.c:427 [opt]
frame #14: 0x000000010b93492f monomono_method_to_ir(cfg=<unavailable>, method=<unavailable>,
start_bblock=0x0000000000000000, end_bblock=0x0000000000000000,
return_var=0x0000000000000000, inline_args=0x0000000000000000,
inline_offset=<unavailable>, is_virtual_call=<unavailable>) at
method-to-ir.c:6674 [opt]
frame #15: 0x000000010b91ade7 monomini_method_compile(method=, opts=374434303,
domain=0x00007fbc91f02f00, flags=JIT_FLAG_RUN_CCTORS, parts=0,
aot_method_index=-1) at mini.c:3455 [opt]
frame #16: 0x000000010b91e32c monomono_jit_compile_method_inner(method=0x00007fbc94832ea8,
target_domain=0x00007fbc91f02f00, opt=<unavailable>,
error=0x00007ffee42ebd60) at mini.c:4043 [opt]
frame #17: 0x000000010b921cc9 monomono_jit_compile_method_with_opt(method=0x00007fbc94832ea8,
opt=, jit_only=1, error=0x00007ffee42ebd60) at
mini-runtime.c:2411 [opt]
frame #18: 0x000000010b925d8e monomono_jit_runtime_invoke [inlined] mono_jit_compile_method_jit_only(method=<unavailable>,
error=0x00007ffee42ebd60) at mini-runtime.c:2471 [opt]
frame #19: 0x000000010b925d6e monomono_jit_runtime_invoke(method=, obj=,
params=0x0000000000000000, exc=,
error=0x00007ffee42ebd60) at mini-runtime.c:3011 [opt]
frame #20: 0x000000010bb241d4 monodo_runtime_invoke(method=0x00007fbc94832ea8,
obj=0x0000000000000000, params=0x0000000000000000,
exc=0x00007ffee42ebd08, error=0x00007ffee42ebd60) at object.c:2960
[opt]
frame #21: 0x000000010bb201a8 monomono_runtime_class_init_full [inlined] mono_runtime_try_invoke(method=,
obj=, params=, error=0x00007ffee42ebd60) at
object.c:3069 [opt]
frame #22: 0x000000010bb20167 monomono_runtime_class_init_full(vtable=0x00007fbc9402ee60,
error=0x00007ffee42ebd60) at object.c:526 [opt]
frame #23: 0x000000010b97a69c monomono_generic_class_init(vtable=) at
jit-icalls.c:1511 [opt]
frame #24: 0x000000010beb7e2c
frame #25: 0x000000010b9261d3 monomono_jit_runtime_invoke(method=<unavailable>, obj=<unavailable>,
params=0x00007ffee42ec148, exc=0x00007fbc9402ee60,
error=<unavailable>) at mini-runtime.c:3148 [opt]
frame #26: 0x000000010bb241d4 monodo_runtime_invoke(method=0x00007fbc91f04798,
obj=0x0000000000000000, params=0x00007ffee42ec148,
exc=0x0000000000000000, error=0x00007ffee42ec180) at object.c:2960
[opt]
frame #27: 0x000000010bb27cac monodo_exec_main_checked [inlined] mono_runtime_invoke_checked(method=<unavailable>, obj=<unavailable>,
params=<unavailable>, error=0x00007ffee42ec180) at object.c:3128 [opt]
frame #28: 0x000000010bb27c9d monodo_exec_main_checked(method=0x00007fbc91f04798,
args=, error=0x00007ffee42ec180) at object.c:4949 [opt]
frame #29: 0x000000010b98d19d monomono_jit_exec at driver.g.c:1236 [opt]
frame #30: 0x000000010b98d18f monomono_jit_exec(domain=, assembly=,
argc=1, argv=0x00007ffee42ec550) at driver.g.c:1195 [opt]
frame #31: 0x000000010b99037f monomono_main [inlined] main_thread_handler at driver.g.c:1313 [opt]
frame #32: 0x000000010b990348 monomono_main(argc=4, argv=) at driver.g.c:2483 [opt]
frame #33: 0x000000010b915078 monomain [inlined] mono_main_with_options(argc=<unavailable>, argv=<unavailable>) at
main.c:50 [opt]
frame #34: 0x000000010b915064 monomain(argc=4, argv=) at main.c:405 [opt]
frame #35: 0x00007fff71b8ced9 libdyld.dylibstart + 1
frame #36: 0x00007fff71b8ced9 libdyld.dylibstart + 1 thread #2, name = 'SGen worker'
frame #0: 0x00007fff71cc97de libsystem_kernel.dylib__psynch_cvwait + 10
frame #1: 0x00007fff71d83593 libsystem_pthread.dylib_pthread_cond_wait + 724
frame #2: 0x000000010bbf10ee monothread_func [inlined] mono_os_cond_wait(mutex=<unavailable>) at mono-os-mutex.h:173 [opt]
frame #3: 0x000000010bbf10db monothread_func at sgen-thread-pool.c:165 [opt]
frame #4: 0x000000010bbf10cd monothread_func(data=0x0000000000000000) at sgen-thread-pool.c:196
[opt]
frame #5: 0x00007fff71d80305 libsystem_pthread.dylib_pthread_body + 126
frame #6: 0x00007fff71d8326f libsystem_pthread.dylib_pthread_start + 70
frame #7: 0x00007fff71d7f415 libsystem_pthread.dylibthread_start + 13 thread #3, name = 'Finalizer'
frame #0: 0x00007fff71cc61b6 libsystem_kernel.dylibsemaphore_wait_trap + 10
frame #1: 0x000000010bb9e9aa monofinalizer_thread [inlined] mono_os_sem_wait(flags=MONO_SEM_FLAGS_ALERTABLE) at
mono-os-semaphore.h:90 [opt]
frame #2: 0x000000010bb9e99f monofinalizer_thread at mono-coop-semaphore.h:43 [opt]
frame #3: 0x000000010bb9e985 monofinalizer_thread(unused=) at gc.c:918 [opt]
frame #4: 0x000000010bb49e13 monostart_wrapper [inlined] start_wrapper_internal at threads.c:1151 [opt]
frame #5: 0x000000010bb49d83 monostart_wrapper(data=0x00007fbc91f34850) at threads.c:1211 [opt]
frame #6: 0x00007fff71d80305 libsystem_pthread.dylib_pthread_body + 126
frame #7: 0x00007fff71d8326f libsystem_pthread.dylib_pthread_start + 70
frame #8: 0x00007fff71d7f415 libsystem_pthread.dylibthread_start + 13 thread #4, name = 'Debugger agent'
frame #0: 0x00007fff71cc93e6 libsystem_kernel.dylib__recvfrom + 10
frame #1: 0x000000010ba7e45e monosocket_transport_recv(buf=2001-01-01 00:00:00 UTC, len=11) at
debugger-agent.c:1108 [opt]
frame #2: 0x000000010ba6f296 monodebugger_thread [inlined] transport_recv(len=11) at debugger-agent.c:1518 [opt]
frame #3: 0x000000010ba6f27c monodebugger_thread(arg=<unavailable>) at debugger-agent.c:9484 [opt]
frame #4: 0x000000010bb49e13 monostart_wrapper [inlined] start_wrapper_internal at threads.c:1151 [opt]
frame #5: 0x000000010bb49d83 monostart_wrapper(data=0x00007fbc91f389a0) at threads.c:1211 [opt]
frame #6: 0x00007fff71d80305 libsystem_pthread.dylib_pthread_body + 126
frame #7: 0x00007fff71d8326f libsystem_pthread.dylib_pthread_start + 70
frame #8: 0x00007fff71d7f415 libsystem_pthread.dylibthread_start + 13 thread #5
frame #0: 0x00007fff71cc7b6a libsystem_kernel.dylib__workq_kernreturn + 10
frame #1: 0x00007fff71d7f630 libsystem_pthread.dylib_pthread_wqthread + 446
frame #2: 0x00007fff71d7f405 libsystem_pthread.dylibstart_wqthread + 13 thread #6
frame #0: 0x00007fff71cc7b6a libsystem_kernel.dylib__workq_kernreturn + 10
frame #1: 0x00007fff71d7f630 libsystem_pthread.dylib_pthread_wqthread + 446
frame #2: 0x00007fff71d7f405 libsystem_pthread.dylibstart_wqthread + 13 (lldb) detach
================================================================= Got a SIGABRT while executing native code. This usually indicates a fatal
error in the mono runtime or one of the native libraries used by your
application.
(lldb) quit Process 1457 detached
It seems an issue with Visual Studio for Mac and Suave. I did the same test in Visual Studio Code (for mac also) and worked fine.

How to find the error when "terminate_handler unexpectedly threw an exception"?

Recently, my app had a crash and it threw an error:
libc++abi.dylib: terminate_handler unexpectedly threw an exception
(lldb) bt
* thread #1: tid = 0x2e8eb, 0x38cf1dfc libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x38cf1dfc libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x38d6fd36 libsystem_pthread.dylib`pthread_kill + 62
frame #2: 0x38c91908 libsystem_c.dylib`abort + 76
frame #3: 0x37fce9c8 libc++abi.dylib`abort_message + 88
frame #4: 0x37fe5e28 libc++abi.dylib`std::__terminate(void (*)()) + 148
frame #5: 0x37fe58ae libc++abi.dylib`__cxa_rethrow + 102
frame #6: 0x386abdd2 libobjc.A.dylib`objc_exception_rethrow + 42
frame #7: 0x2ae0745c CoreFoundation`CFRunLoopRunSpecific + 632
frame #8: 0x2ae071d2 CoreFoundation`CFRunLoopRunInMode + 106
frame #9: 0x322050a8 GraphicsServices`GSEventRunModal + 136
frame #10: 0x2e416fa0 UIKit`UIApplicationMain + 1440
* frame #11: 0x0016c250 hatchpic`top_level_code + 72 at AppDelegate.swift:44
frame #12: 0x0016c3a4 hatchpic`main + 48 at AppDelegate.swift:0
and it did not tell me where the error exactly happens.
What I ended up doing is to figure the problem out by tracking what actions I have taken and tracing back the error manually.
It's quite a frustrating work to do. So how to use lldb, or perhaps other ways than manual approach, to locate where the error exactly happens then?
A similar answer was posted here. You simply add an Exception breakpoint and you set the Exception type to c++. This will pause execution on the function that actually causes the crash.

Crash with EXC_BAD_ACCESS in Xcode - debugging

I occasionally run into a crash with my Mac app, where the debugger stops and catches an EXC_BAD_ACCESS error from main.m. The stack trace looks like as follows:
* thread #1: tid = 0x406ad1, 0x00007fff8be600d7 libobjc.A.dylib`objc_msgSend + 23, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x600036e8de50)
frame #0: 0x00007fff8be600d7 libobjc.A.dylib`objc_msgSend + 23
frame #1: 0x00007fff96edb93b AppKit`_NSPopoverCloseAndAnimate + 1102
frame #2: 0x00007fff9754cfed AppKit`-[NSPopover _geometryInWindowDidChangeForView:] + 166
frame #3: 0x00007fff8bb15cdc CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
frame #4: 0x00007fff8ba07244 CoreFoundation`_CFXNotificationPost + 3140
frame #5: 0x00007fff8ffa6c31 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 66
frame #6: 0x00007fff96ca31c1 AppKit`-[NSView _invalidateFocus] + 421
frame #7: 0x00007fff96ca3c32 AppKit`-[NSView removeFromSuperview] + 469
frame #8: 0x00007fff96ea569a AppKit`-[NSWindow dealloc] + 1233
frame #9: 0x00007fff96ca9857 AppKit`-[NSWindow release] + 193
frame #10: 0x00007fff8ba0f9c0 CoreFoundation`CFRelease + 304
frame #11: 0x00007fff8ba23fad CoreFoundation`-[__NSArrayM dealloc] + 205
frame #12: 0x00007fff8be8089c libobjc.A.dylib`objc_object::sidetable_release(bool) + 236
frame #13: 0x00007fff8be66e8f libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 575
frame #14: 0x00007fff8ba31302 CoreFoundation`_CFAutoreleasePoolPop + 50
frame #15: 0x00007fff8ffbfedf Foundation`-[NSAutoreleasePool drain] + 153
frame #16: 0x00007fff96c7e661 AppKit`-[NSApplication run] + 800
frame #17: 0x00007fff96c69a14 AppKit`NSApplicationMain + 1832
frame #18: 0x0000000100003ec2 Contacts Journal Beta`main(argc=3, argv=0x00007fff5fbff670) + 34 at main.m:13
frame #19: 0x00007fff977c35c9 libdyld.dylib`start + 1
I've tried debugging this with NSZombieEnabled and with the Zombies instrument, and they haven't been helpful. But the debugger does stop at this breakpoint (on the rare occasions I run into this crash), so I'm wondering if there is anything I can do with the debugger to get more information as to which object is causing this crash and why.
Would love some lldb tips. Also, is there any way to force the "NSAutoreleasePool drain" that seems to be part of the stack trace? It seems to me that this is the initial cause of the problem, so any fix would have to trigger an autorelease drain (use ARC in my app).

SIGABRT error in Xcode 4.6

I'm building an app to demonstrate a point for a project and I keep getting the SIGABRT error whenever I run it I have tried using breakpoints but it comes back to the same line of code in main.m:
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
I have typed bt into the debugger and this is what I get:
* thread #1: tid = 0x1c03, 0x96b38a6a libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
frame #0: 0x96b38a6a libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x9244bacf libsystem_c.dylib`pthread_kill + 101
frame #2: 0x04a7657b libsystem_sim_c.dylib`abort + 140
frame #3: 0x04bf6f7b libc++abi.dylib`abort_message + 105
frame #4: 0x04bf4a25 libc++abi.dylib`default_terminate() + 34
frame #5: 0x010cf0c1 libobjc.A.dylib`_objc_terminate() + 94
frame #6: 0x04bf4a65 libc++abi.dylib`safe_handler_caller(void (*)()) + 13
frame #7: 0x04bf4acd libc++abi.dylib`std::terminate() + 23
frame #8: 0x04bf5c4e libc++abi.dylib`__cxa_rethrow + 83
frame #9: 0x010cefbd libobjc.A.dylib`objc_exception_rethrow + 47
frame #10: 0x01c36f98 CoreFoundation`CFRunLoopRunSpecific + 360
frame #11: 0x01c36e1b CoreFoundation`CFRunLoopRunInMode + 123
frame #12: 0x0001117a UIKit`-[UIApplication _run] + 774
frame #13: 0x00012ffc UIKit`UIApplicationMain + 1211
frame #14: 0x000021bd Scooter App`main(argc=1, argv=0xbffff378) + 141 at main.m:16
All help will be gratefully received.

Resources