You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xcode 14.1设置断点时崩溃(错误((void *)0) == existingDocument)求解决方案

Xcode断点触发崩溃问题(((void *)0) == existingDocument)

问题背景

我司iOS基建开发团队近期多位同事遇到Xcode崩溃问题,错误断言为((void *)0) == existingDocument,触发场景为设置断点调试时。

问题触发逻辑分析

当断点触发时,lldb计算源代码URL并通知Xcode跳转至对应行;Xcode根据URL查找文档,若未找到则创建新文档,但在将新文档添加至控制器时,发现已有相同URL的文档,触发断言导致崩溃。

推测核心原因是文档的查找与添加操作并非线程安全,缺少锁机制。例如调试时触发断点的同时,手动打开/切换对应源码文件标签页,就会触发该冲突。

崩溃报告

-------------------------------------
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版本:该问题是Xcode 14.1的已知线程安全缺陷,升级到Xcode 14.2及以上版本可修复(苹果在后续版本中对IDEDocumentController的文档操作添加了锁机制)
  • 重置Xcode状态:执行以下命令重置Xcode缓存与状态,排除环境异常:
    rm -rf ~/Library/Developer/Xcode/DerivedData
    defaults delete com.apple.dt.Xcode
    killall -9 Xcode
    
  • 禁用自动变量视图:在Xcode调试界面关闭自动变量列表的自动更新(Debugger UI设置中关闭Auto Update Variables),减少断点触发时的文档请求操作

长期修复建议

如果团队无法立即升级Xcode,可通过内部规范约束调试操作流程,同时优先推动版本升级彻底解决线程安全问题。


内容的提问来源于stack exchange,提问作者Wenbo Cao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 22:49:53