海森堡-> NSInvalidArgumentException:容量太荒谬了
我遇到了一次非常令人困惑的崩溃,我目前已经耗尽了我的智慧......
首先是崩溃日志:
日期/时间:2012-02-14 10:55:09.771 +0100
操作系统版本:Mac OS X 10.7.3 (11D50b)
报告版本:9
崩溃线程:0
异常类型:EXC_CRASH (SIGABRT)
异常代码:0x0000000000000000、0x0000000000000000
应用程序特定信息:
iPhone 模拟器 272,iPhone OS 5.0 (iPhone/9A334)
abort() 调用
* 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“* -[__NSPlaceholderDictionary initWithCapacity:]: 容量 (2147483648) 很荒谬” * 第一个抛出调用堆栈: (0x25ca052 0x21d8d0a 0x24f21b7 0x252597b 0x688e2 0x6a3b5 0x41b2f 0x1f29d 0x1f87e 0xba335c 0xbabd0d 0xcc8a1c 0xcc93a9 0xf3de39 0xf3d143 0xf3e3cf 0xf40a31 0xf4098c 0xf393e7 0xca1812 0xca1ba2 0xc88384 0xc7baa9 0x2333fa9 0x259e1c5 0x2503022 0x250190a 0x2500db4 0x2500ccb 0x2332879 0x233293e 0xc79a9b 0x23ad 0x2325)
线程 0 崩溃:
0 libsystem_kernel.dylib 0x983379c6 __pthread_kill + 10
1 libsystem_c.dylib 0x939e7f78 pthread_kill + 106
2 libsystem_c.dylib 0x939d8bdd 中止 + 167
3 libc++abi.dylib 0x01fa5e78 abort_message + 50
4 libc++abi.dylib 0x01fa389e _ZL17default_terminatev + 34
5 libobjc.A.dylib 0x021d8f4b _objc_terminate + 94
6 libc++abi.dylib 0x01fa38de _ZL19safe_handler_callerPFvvE + 13
7 libc++abi.dylib 0x01fa3946 std::terminate() + 23
8 libc++abi.dylib 0x01fa4b3e __cxa_rethrow + 83
9 libobjc.A.dylib 0x021d8e49 objc_exception_rethrow + 47
10 CoreFoundation 0x02500e10 CFRunLoopRunSpecific + 304
11 CoreFoundation 0x02500ccb CFRunLoopRunInMode + 123
12 图形服务 0x02332879 GSEventRunModal + 207
13 图形服务 0x0233293e GSEventRun + 114
14 UIKit 0x00c79a9b UIApplicationMain + 1175
15 LVM 0x000023ad 主 + 125 (main.m:14)
16 LVM 0x00002325 start + 53
我正在 Lion 10.7.3 和 Xcode 4.2 下工作。 分析器没有指示错误,并且该项目直到昨天都运行稳定。 该错误本身不是在设置过程中引起的,而是由重新加载要显示的必要数据的手势引起的。
乍一看似乎很清楚:我分配了一个具有无效容量的 NSDictionary 实例(2147483648 实际上是一个带符号的 -2147483648,因此它可能是一个溢出工件)。
- 我的系统具有在发生崩溃时停止的所有必要设置:NSZombieEnabled, obj_exc_throw 等。好吧,它停止了,但是在 main.m 的主循环中。所以没有信息可看。
- 所以我查找了所有 NSXXDictionary 实例并保证它们都有常量 容量初始值设定项或使用它们的[...字典]分配。第一个惊喜:它仍然 崩溃。
- 好的,Xcode 有时可能无法正确重新编译更改? Xcode 关闭, 清理,重建,扔掉构建目录(构建,缓存,dstroot),重新启动,任何事情。 还是同样的崩溃。
- 正如你所看到的,它在运行循环中崩溃了,所以我没有得到太多关于 地点。好的,启动 Profile->System Trace 并查看是否可以找到....系统跟踪崩溃! 8-0
- Erm....我的同事对当前的更改没有问题,所以我尝试使用 SVN 查找 问题到底出现在哪里。在这里我再次陷入困境:错误消失了并且 出现,所以我无法确定原因。
那么...是否有任何其他数据结构(NSArray 等)或函数可能导致这种奇怪的行为?或者你有什么好的调试技巧来确定它吗? 感谢您提供任何有用的帮助。
编辑:发现错误,是我自己:(。请参阅下面的答案
I get a very confusing crash where I am currently running out of my wisdom...
First the crash log:
Date/Time: 2012-02-14 10:55:09.771 +0100
OS Version: Mac OS X 10.7.3 (11D50b)
Report Version: 9
Crashed Thread: 0
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
iPhone Simulator 272, iPhone OS 5.0 (iPhone/9A334)
abort() called
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderDictionary initWithCapacity:]: capacity (2147483648) is ridiculous'
* First throw call stack:
(0x25ca052 0x21d8d0a 0x24f21b7 0x252597b 0x688e2 0x6a3b5 0x41b2f 0x1f29d 0x1f87e 0xba335c 0xbabd0d 0xcc8a1c 0xcc93a9 0xf3de39 0xf3d143 0xf3e3cf 0xf40a31 0xf4098c 0xf393e7 0xca1812 0xca1ba2 0xc88384 0xc7baa9 0x2333fa9 0x259e1c5 0x2503022 0x250190a 0x2500db4 0x2500ccb 0x2332879 0x233293e 0xc79a9b 0x23ad 0x2325)
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x983379c6 __pthread_kill + 10
1 libsystem_c.dylib 0x939e7f78 pthread_kill + 106
2 libsystem_c.dylib 0x939d8bdd abort + 167
3 libc++abi.dylib 0x01fa5e78 abort_message + 50
4 libc++abi.dylib 0x01fa389e _ZL17default_terminatev + 34
5 libobjc.A.dylib 0x021d8f4b _objc_terminate + 94
6 libc++abi.dylib 0x01fa38de _ZL19safe_handler_callerPFvvE + 13
7 libc++abi.dylib 0x01fa3946 std::terminate() + 23
8 libc++abi.dylib 0x01fa4b3e __cxa_rethrow + 83
9 libobjc.A.dylib 0x021d8e49 objc_exception_rethrow + 47
10 CoreFoundation 0x02500e10 CFRunLoopRunSpecific + 304
11 CoreFoundation 0x02500ccb CFRunLoopRunInMode + 123
12 GraphicsServices 0x02332879 GSEventRunModal + 207
13 GraphicsServices 0x0233293e GSEventRun + 114
14 UIKit 0x00c79a9b UIApplicationMain + 1175
15 LVM 0x000023ad main + 125 (main.m:14)
16 LVM 0x00002325 start + 53
I am working under Lion 10.7.3 with Xcode 4.2.
The analyzer does not indicate an error and the project was running stable until yesterday.
The error itself is not caused during setup, but by a gesture which reloads the necessary data to display.
At the first glance it seems to be clear: I have allocated a NSDictionary instance with an invalid capacity (2147483648 is in fact a signed -2147483648 so it may be an overflow artifact).
- My system has all the necessary settings to stop when a crash occurs: NSZombieEnabled,
obj_exc_throw etc. Well, it stops, but in the main loop in main.m. So no info to see. - So I looked up all my NSXXDictionary instances and guaranteed that they all have constant
capacity initializers or use their [... dictionary] allocations. First surprise: It still
crashes. - Ok, it may be that Xcode sometimes does not recompile changes correctly ? Xcode closed,
clean, rebuild, throwing the build dir (build, caches, dstroot) away, restart, anything.
Still the same crash. - As you see, it crashes in the running loop so I don't get much information about the
location. Ok, start up Profile->System Trace and look if I can find....System trace crashes ! 8-0 - Erm....my coworkers have no problem with the current changes, so I tried to find with SVN
where exactly the problems arise. And here I am again stuck: The error disappears and
appears so I cannot pin down the cause.
So...are there any other datastructures (NSArray etc.) or functions which may cause this strange behavior ? Or do you have any good debugging tips to pin it down ?
Thanks for any useful help.
EDIT: The error was found and it was myself :(. See answer below
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
又是自己的愚蠢规则......
如果您遇到相同的错误,请搜索所有可能的构造函数。事实上,我忽略了一个 [NSXXDictionary DictionaryWithCapacity] 构造函数,其中容量实际上是非法值。它被称为深度嵌套在运行时循环中。
我只搜索了initWithCapacity,因为我通常只使用没有容量的字典构造函数,我无意识的假设自然是错误的。
And again the own stupidity rules....
If you hit the same error, please search for all possible constructors. I have in fact overlooked one [NSXXDictionary dictionaryWithCapacity] constructor where in fact the capacity was an illegal value. It is called deeply nested in the runtime loop.
I only searched for initWithCapacity because I normally used only the dictionary constructor without capacity and my unconscious assumption was naturally wrong.
当我在 obj_exc_throw 设置断点并且断点被击中时,按下调试器的继续按钮可以让应用程序崩溃。然后您应该能够看到所需的堆栈跟踪。
When I have a breakpoint set at
obj_exc_throw
and the breakpoint gets hit, it helps to hit the debugger's continue button to let the app crash. Then you should be able to see the needed stack trace.