Cocoa应用程序中无法解释的NSUndoManager崩溃/断言

时间:2010-09-05 10:40:18

标签: multithreading cocoa crash assert nsundomanager

我有一个奇怪的问题,我正在研究一个Cocoa,OpenGL应用程序。每当我启动我的应用程序时,我在控制台上收到以下消息/断言失败,与eh NSUndoManager相关。顺便说一下,我没有使用撤消管理器。

2010-09-05 03:28:49.184 CocoaCoreTest[51721:a0f] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-751.29/Misc.subproj/NSUndoManager.m:271
2010-09-05 03:28:49.188 CocoaCoreTest[51721:a0f] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2010-09-05 03:28:49.189 CocoaCoreTest[51721:a0f] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-751.29/Misc.subproj/NSUndoManager.m:271
2010-09-05 03:28:49.190 CocoaCoreTest[51721:a0f] An uncaught exception was raised 2010-09-05 03:28:49.190 CocoaCoreTest[51721:a0f] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2010-09-05 03:28:49.192 CocoaCoreTest[51721:a0f] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** Call stack at first throw: ( 0 CoreFoundation 0x00007fff83e97cc4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff883bb0f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff83e97ae7 +[NSException raise:format:arguments:] + 103
3 Foundation 0x00007fff84cf2d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 Foundation 0x00007fff84c4b936 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 140
5 AppKit 0x00007fff823219f9 -[NSApplication run] + 689
6 AppKit 0x00007fff8231a5f8 NSApplicationMain + 364
7 CocoaCoreTest 0x000000010003b753 main + 33
8 CocoaCoreTest 0x0000000100021608 start + 52
9 ??? 0x0000000000000001 0x0 + 1
) terminate called after throwing an instance of 'NSException'

我正在主线程上运行我的GUI,事实上我并没有产生任何其他线程。当我为x86_64编译时,我在调试和发布模式下遇到此崩溃。但是,有趣的是,当我为i386编译时,不会发生此错误。

感谢您的帮助!

弗洛里安

1 个答案:

答案 0 :(得分:1)

我正在使用POSIX线程本地存储。尽管我的应用程序当前是单线程的,即使我的TLS变量定期,线程全局变量可以缓解崩溃。每个变量应该只有一个TLS实例。

有关为什么POSIX TLS可能无法与Cocoa一起使用的任何评论。这是一个已知的问题吗?