Kode / Krom

Other
97 stars 23 forks source link

macOS: reliable crash on debugging #76

Open poke1024 opened 6 years ago

poke1024 commented 6 years ago

On macOS, Krom always crashes for me when started from inside Kode Studio and then quitting (i.e. Krom crashes when closing its window/closing the app).

I didn't manage to get a crash report/stack trace for this (though trying hard).

The reasons seems to be debugging. If I disable debugging by removing '--debug', port.toString() from the launch command line in KodeStudio.app/Contents/Resources/app/extensions/krom-debug/out/chromeDebugAdapter.js, things work fine.

Also, strangely, if I run with debug flags from the command line with some bogus port (e.g. mykrom/macos/Krom.app/Contents/MacOS/Krom myproject/build/krom --debug 8080), there's no crash on quitting Krom.

The main annoyance with this is that macOS will ask on every new start of Krom, if you really want to launch it, as it crashed last time.

poke1024 commented 6 years ago

Finally produced a stack trace:

Process:               Krom [94626]
Path:                  /private/var/folders/*/Kode Studio.app/Contents/Resources/app/extensions/krom/Krom/macos/Krom.app/Contents/MacOS/Krom
Identifier:            com.ktxsoftware.Krom
Version:               1.0 (1)
Code Type:             X86-64 (Native)
Parent Process:        Kode Studio Helper [94616]
Responsible:           Krom [94626]
User ID:               502

Date/Time:             2018-07-29 10:48:15.576 +0200
OS Version:            Mac OS X 10.13.6 (17G65)
Report Version:        12
Bridge OS Version:     3.0 (14Y664)
Anonymous UUID:        75C7B990-F9F4-1764-0843-B6519F7CAD0C

Sleep/Wake UUID:       8AE8A8C4-9C1F-4D8E-B729-E4DD281209C0

Time Awake Since Boot: 85000 seconds
Time Since Wake:       1700 seconds

System Integrity Protection: enabled

Notes:                 Translocated Process

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000050c0
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [0]

VM Regions Near 0x50c0:
--> 
    __TEXT                 0000000103980000-00000001039f0000 [  448K] r-x/rwx SM=COW  /var/folders/*/Kode Studio.app/Contents/Resources/app/extensions/krom/Krom/macos/Krom.app/Contents/MacOS/Krom

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libv8.dylib                     0x0000000103a1b558 v8::HandleScope::Initialize(v8::Isolate*) + 88
1   libv8.dylib                     0x000000010418013e v8_inspector::(anonymous namespace)::ActualScript::resetBlackboxedStateCache() + 30
2   libv8.dylib                     0x0000000104174dca v8_inspector::V8DebuggerAgentImpl::disable() + 762
3   libv8.dylib                     0x00000001041937d4 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() + 356
4   libv8.dylib                     0x000000010419398e v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() + 14
5   libsystem_c.dylib               0x00007fff7370deed __cxa_finalize_ranges + 351
6   libsystem_c.dylib               0x00007fff7370e1fe exit + 55
7   com.ktxsoftware.Krom            0x0000000103983dd9 0x103980000 + 15833
8   com.ktxsoftware.Krom            0x00000001039a20fd 0x103980000 + 139517
9   com.apple.Foundation            0x00007fff4d92a5a0 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 1123
10  com.apple.Foundation            0x00007fff4d92a0bf -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 131
11  com.ktxsoftware.Krom            0x00000001039a209e 0x103980000 + 139422
12  libdyld.dylib                   0x00007fff73661015 start + 1

Thread 1:
0   libsystem_kernel.dylib          0x00007fff737b228a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff73979009 _pthread_wqthread + 1035
2   libsystem_pthread.dylib         0x00007fff73978be9 start_wqthread + 13

Thread 2:
0   libsystem_kernel.dylib          0x00007fff737b228a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff7397920e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff73978be9 start_wqthread + 13

Thread 3:
0   libsystem_kernel.dylib          0x00007fff737b228a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff73979009 _pthread_wqthread + 1035
2   libsystem_pthread.dylib         0x00007fff73978be9 start_wqthread + 13

Thread 4:
0   libsystem_kernel.dylib          0x00007fff737b228a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff7397920e _pthread_wqthread + 1552
2   libsystem_pthread.dylib         0x00007fff73978be9 start_wqthread + 13

Thread 5:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff737a8246 semaphore_wait_trap + 10
1   libv8_libbase.dylib             0x000000010458b9b7 v8::base::Semaphore::Wait() + 23
2   libv8_libplatform.dylib         0x00000001045710d0 v8::platform::TaskQueue::GetNext() + 48
3   libv8_libplatform.dylib         0x000000010457686b v8::platform::WorkerThread::Run() + 43
4   libv8_libbase.dylib             0x000000010458d4a7 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
6   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
7   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 6:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff737a8246 semaphore_wait_trap + 10
1   libv8_libbase.dylib             0x000000010458b9b7 v8::base::Semaphore::Wait() + 23
2   libv8_libplatform.dylib         0x00000001045710d0 v8::platform::TaskQueue::GetNext() + 48
3   libv8_libplatform.dylib         0x000000010457686b v8::platform::WorkerThread::Run() + 43
4   libv8_libbase.dylib             0x000000010458d4a7 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
6   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
7   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 7:: V8 WorkerThread
0   libsystem_kernel.dylib          0x00007fff737a8246 semaphore_wait_trap + 10
1   libv8_libbase.dylib             0x000000010458b9b7 v8::base::Semaphore::Wait() + 23
2   libv8_libplatform.dylib         0x00000001045710d0 v8::platform::TaskQueue::GetNext() + 48
3   libv8_libplatform.dylib         0x000000010457686b v8::platform::WorkerThread::Run() + 43
4   libv8_libbase.dylib             0x000000010458d4a7 v8::base::ThreadEntry(void*) + 87
5   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
6   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
7   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 8:
0   libsystem_kernel.dylib          0x00007fff737b1c32 __recvfrom + 10
1   com.ktxsoftware.Krom            0x00000001039821a5 0x103980000 + 8613
2   com.ktxsoftware.Krom            0x000000010399f995 0x103980000 + 129429
3   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
4   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
5   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 9:
0   libsystem_kernel.dylib          0x00007fff737a825e semaphore_timedwait_trap + 10
1   libdispatch.dylib               0x00007fff7363794f _dispatch_sema4_timedwait + 72
2   libdispatch.dylib               0x00007fff7362f94e _dispatch_semaphore_wait_slow + 58
3   libdispatch.dylib               0x00007fff7362ae53 _dispatch_worker_thread + 251
4   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
5   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
6   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 10:: com.apple.audio.IOThread.client
0   libsystem_kernel.dylib          0x00007fff737a820a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff737a7724 mach_msg + 60
2   com.apple.audio.CoreAudio       0x00007fff4b27987a HALB_MachPort::SendMessageWithReply(unsigned int, unsigned int, unsigned int, unsigned int, mach_msg_header_t*, bool, unsigned int) + 124
3   com.apple.audio.CoreAudio       0x00007fff4b2797ed HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 45
4   com.apple.audio.CoreAudio       0x00007fff4b276859 HALC_ProxyIOContext::IOWorkLoop() + 977
5   com.apple.audio.CoreAudio       0x00007fff4b2762bc HALC_ProxyIOContext::IOThreadEntry(void*) + 128
6   com.apple.audio.CoreAudio       0x00007fff4b275ffe HALB_IOThread::Entry(void*) + 72
7   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
8   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
9   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 11:: com.apple.NSEventThread
0   libsystem_kernel.dylib          0x00007fff737a820a mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff737a7724 mach_msg + 60
2   com.apple.CoreFoundation        0x00007fff4b821785 __CFRunLoopServiceMachPort + 341
3   com.apple.CoreFoundation        0x00007fff4b820ad7 __CFRunLoopRun + 1783
4   com.apple.CoreFoundation        0x00007fff4b820153 CFRunLoopRunSpecific + 483
5   com.apple.AppKit                0x00007fff48ef8fc4 _NSEventThread + 184
6   libsystem_pthread.dylib         0x00007fff73979661 _pthread_body + 340
7   libsystem_pthread.dylib         0x00007fff7397950d _pthread_start + 377
8   libsystem_pthread.dylib         0x00007fff73978bf9 thread_start + 13

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x000000000000010e  rbx: 0x00007fe191056200  rcx: 0x0000000000000000  rdx: 0x0000000000023230
  rdi: 0x000000000000010f  rsi: 0x00007fe191056200  rbp: 0x00007ffeec27f090  rsp: 0x00007ffeec27f070
   r8: 0x0000000000000002   r9: 0x00007fe190dc5b20  r10: 0x000007fe190d24ec  r11: 0x0000000000000003
  r12: 0x00007fe190f66cc0  r13: 0x00007fe190f66dd0  r14: 0x00007ffeec27f0a8  r15: 0x0000000000000000
  rip: 0x0000000103a1b558  rfl: 0x0000000000010246  cr2: 0x00000000000050c0

Logical CPU:     1
Error Code:      0x00000004
Trap Number:     14

EDIT and a second one, in the audio callback:

==== C stack trace ===============================

0   libv8_libbase.dylib                 0x00000001015c00c3 v8::base::debug::StackTrace::StackTrace() + 19
1   libv8_libplatform.dylib             0x0000000101599399 v8::platform::(anonymous namespace)::PrintStackTrace() + 41
2   libv8_libbase.dylib                 0x00000001015bb97c V8_Fatal(char const*, int, char const*, ...) + 220
3   libv8.dylib                         0x000000010026276c v8::Utils::OpenHandle(v8::Context const*, bool) + 252
4   libv8.dylib                         0x0000000100264454 v8::Context::Enter() + 36
5   Krom                                0x0000000100117d4b v8::Context::Scope::Scope(v8::Local<v8::Context>) + 43
6   Krom                                0x0000000100117bad v8::Context::Scope::Scope(v8::Local<v8::Context>) + 29
7   Krom                                0x000000010011785c (anonymous namespace)::updateAudio(int) + 172
8   Krom                                0x0000000100114fe3 (anonymous namespace)::mix(int) + 19
9   Krom                                0x000000010013736e (anonymous namespace)::appIOProc(unsigned int, AudioTimeStamp const*, AudioBufferList const*, AudioTimeStamp const*, AudioBufferList*, AudioTimeStamp const*, void*) + 78
10  CoreAudio                           0x00007fff4b277825 HALC_ProxyIOContext::IOWorkLoop() + 5021
11  CoreAudio                           0x00007fff4b2762bc HALC_ProxyIOContext::IOThreadEntry(void*) + 128
12  CoreAudio                           0x00007fff4b275ffe HALB_IOThread::Entry(void*) + 72
13  libsystem_pthread.dylib             0x00007fff73979661 _pthread_body + 340
14  libsystem_pthread.dylib             0x00007fff7397950d _pthread_body + 0
15  libsystem_pthread.dylib             0x00007fff73978bf9 thread_start + 13

Received signal 4 0001015be9b2 Illegal instruction: 4