I am an iOS infrastructure developer at our company. Recently, many colleagues have encountered Xcode crash issues showing ((void *)0) == existingDocument.
Basically, this issue occurs when setting breakpoints and the root cause is as follows:
lldb needs to calculate the URL of the source code and tell Xcode to jump to the specified line of that file. Xcode will then try to find the corresponding document based on the URL. If it cannot find the document, it will create a new one. However, when adding a new document to the controller, it discovers that there is already an existing document with the same URL, which leads to a crash.
It is possible that the process of finding and adding documents is not thread-safe and lacks locking mechanisms.
For example, during debugging, if you enter a breakpoint and simultaneously open the corresponding source code file or switch to an inactive tab, this issue may occur.
I would like to know how to solve this problem.
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process: Xcode [2005]
Path: /Applications/Xcode14.1.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 14.1 (21534.1)
Build Info: IDEFrameworks-21534001000000000~2 (14B47b)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
User ID: 501
Date/Time: 2023-04-19 16:38:59.0906 +0800
OS Version: macOS 13.2 (22D49)
Report Version: 12
Anonymous UUID: 2E59D9F5-77A9-4454-324D-54BBEFFB334F
Sleep/Wake UUID: 3F42DEBA-451F-4B4B-94AB-E630D6AD6BE8
Time Awake Since Boot: 24000 seconds
Time Since Wake: 9447 seconds
System Integrity Protection: enabled
Notes:
dyld_process_snapshot_create_for_process failed with 5
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Signatures:
((void *)0) == existingDocument
Error Formulating Crash Report:
dyld_process_snapshot_create_for_process failed with 5
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x196466868 __pthread_kill + 8
1 libsystem_pthread.dylib 0x19649dcec pthread_kill + 288
2 libsystem_c.dylib 0x1963d62c8 abort + 180
3 IDEKit 0x105748b34 +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 980
4 IDEKit 0x105748f74 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 872
5 DVTFoundation 0x10217471c _DVTAssertionHandler + 424
6 DVTFoundation 0x10217489c _DVTAssertionFailureHandler + 196
7 IDEKit 0x10597fb2c -[IDEDocumentController addDocument:] + 960
8 IDEKit 0x105970e3c +[IDEDocumentController retainEditorDocument:] + 520
9 IDEKit 0x105972aa8 __66+[IDEDocumentController _retainedEditorDocumentForURL:type:error:]_block_invoke + 160
10 IDEKit 0x105971a04 +[IDEDocumentController performDocumentTransaction:] + 152
11 IDEKit 0x1059727f0 +[IDEDocumentController _retainedEditorDocumentForURL:type:error:] + 528
12 IDEKit 0x105972db8 +[IDEDocumentController retainedEditorDocumentForDocumentURL:documentType:forUseWithWorkspaceDocument:error:] + 68
13 IDEKit 0x105972cbc +[IDEDocumentController retainedEditorDocumentForDocumentLocation:forUseWithWorkspaceDocument:error:] + 180
14 DebuggerUI 0x2c2aad6e8 -[DBGVariablesViewContentProvider _updateAutoValues] + 344
15 DebuggerUI 0x2c2aac2d4 -[DBGVariablesViewContentProvider _autoVariablesList] + 60
16 DebuggerUI 0x2c2aac1c0 -[DBGVariablesViewContentProvider _autoVariablesListReady] + 60
17 DebuggerUI 0x2c2aac138 -[DBGVariablesViewContentProvider _filteredListNeedsUpdatingImmediately] + 616
18 Foundation 0x1974a3e60 __NSFireDelayedPerform + 372
19 CoreFoundation 0x19659754c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32
20 CoreFoundation 0x1965971f4 __CFRunLoopDoTimer + 940
21 CoreFoundation 0x196596d4c __CFRunLoopDoTimers + 356
22 CoreFoundation 0x19657c734 __CFRunLoopRun + 1896
23 CoreFoundation 0x19657b878 CFRunLoopRunSpecific + 612
24 HIToolbox 0x19fc5bfa0 RunCurrentEventLoopInMode + 292
25 HIToolbox 0x19fc5bde4 ReceiveNextEventCommon + 672
26 HIToolbox 0x19fc5bb2c _BlockUntilNextEventMatchingListInModeWithFilter + 72
27 AppKit 0x199801838 _DPSNextEvent + 632
28 AppKit 0x1998009c8 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
29 DVTKit 0x101191888 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 300
30 AppKit 0x1997f4df8 -[NSApplication run] + 464
31 DVTKit 0x101190a90 -[DVTApplication run] + 60
32 AppKit 0x1997cc23c NSApplicationMain + 880
33 dyld 0x196173e50 start + 2544
Xcode-2023-04-19-163921.txt