Skip to content

Conversation

@kealdishx
Copy link
Contributor

@kealdishx kealdishx commented Mar 5, 2020

We found some crashes inside kscrash like the following

Exception Type: EXC_BAD_ACCESS ( SIGBUS )
Diagnosis: Attempted to dereference garbage pointer 0x14570808c.Originated at or in a subcall of unknown, cannot find symbol

0 | xxxxxx | ksmc_resumeEnvironment(KSMachineContext.c:231)
-- | -- | --
1 | xxxxxx | CPPExceptionTerminate()(KSCrashMonitor_CPPException.cpp:200)
2 | libc++abi.dylib | std::__terminate(void (*)())()
3 | libc++abi.dylib | ___cxa_throw()
4 | libobjc.A.dylib | _objc_exception_throw()
5 | Foundation | __NSOutOfMemoryErrorHandler()
6 | CoreFoundation | ___CFSafelyReallocate()
7 | Foundation | __NSMutableDataGrowBytes()
8 | Foundation | -[NSConcreteMutableData appendBytes:length:]()
9 | ImageIO | IIOImageWriteSession::putBytes(void const*, unsigned long)()
10 | ImageIO | write_fn(png_struct_def*, unsigned char*, unsigned long)()
11 | ImageIO | _png_write_chunk_data()
12 | ImageIO | __cg_png_write_complete_chunk()
13 | ImageIO | _png_compress_IDAT()
......
22 | libdispatch.dylib | __dispatch_call_block_and_release()
23 | libdispatch.dylib | __dispatch_client_callout()
24 | libdispatch.dylib | __dispatch_queue_override_invoke$VARIANT$armv81()
25 | libdispatch.dylib | __dispatch_root_queue_drain()
26 | libdispatch.dylib | __dispatch_worker_thread3()
27 | libsystem_pthread.dylib | __pthread_wqthread()

It seems the cause is a race condition where g_suspendedThreads was released while still being accessed. My solution is to save suspended threads in local variable instead of global variable, since suspend thread and resume thread are always called in pair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant