1

我在 arc4random 调用期间遇到了奇怪的崩溃,该调用仅在应用程序运行大约 4 分钟后才出现,而且并非每次都这样做。这是崩溃日志:

Incident Identifier: 25C8C57F-0434-40B2-A2E8-FE88F58ABF60
CrashReporter Key:   8683ce910e9db4ba69f61266b606396f941d08ee
Hardware Model:      iPhone2,1
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2011-01-16 18:46:45.170 +0000
OS Version:      iPhone OS 4.2.1 (8C148a)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  0

Application Specific Information:
<App> failed to resume in time

Elapsed total CPU time (seconds): 5.930 (user 5.380, system 0.550), 100% CPU 
Elapsed application CPU time (seconds): 4.790, 81% CPU

Thread 0:
0   libSystem.B.dylib              0x31168006 pthread_mutex_lock + 50
1   libSystem.B.dylib              0x3118cb10 arc4random + 24
2   <App>                   0x0000f658 -[BasicGameLayer updateBoard] (BasicGameScreen.mm:318)
3   <App>                    0x00010790 -[BasicGameLayer handleTouches:withEvent:] (BasicGameScreen.mm:238)
4   <App>                   0x0000e504 -[BasicGameLayer ccTouchesBegan:withEvent:] (BasicGameScreen.mm:276)

BasicGameScreen.mm 的第 318 行是一个左大括号。我假设编译器正在删除空格,所以我认为它崩溃的行是

int selection = arc4random() % 16;
4

2 回答 2

4

线索在这里:

异常代码:0x8badf00d

这意味着您在启动时正在执行的操作需要很长时间才能完成执行。

于 2011-01-16T19:27:40.577 回答
0

事实证明,这是一个无限循环(在我的代码中),是在非常特定的变量组合下触发的。

于 2011-04-15T11:36:54.770 回答