gpt4 book ai didi

iphone - 奇怪的 iOS 崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:50:40 25 4
gpt4 key购买 nike

我在仅在设备上发布的版本中发生了非常间歇性的崩溃。这是崩溃日志的相关部分:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000f
Crashed Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x357c6fbc objc_msgSend + 16
1 CoreFoundation 0x33ff9020 CFRetain + 76
2 GraphicsServices 0x35c45af2 GSFontCreateWithName + 178
3 UIKit 0x3514264c UINewFont + 52
4 UIKit 0x351425fc +[UIFont systemFontOfSize:traits:] + 12
5 MyApp 0x0002bc68 -[STDrawer createButtonWithTitle:backgroundColor:] (STDrawer.mm:284)
6 MyApp 0x0002b8e0 -[STDrawer displayActionButtonsWithTitlesArray:] (STDrawer.mm:179)
7 MyApp 0x0002b7e0 -[STDrawer displayActionButtonsWithTitles:] (STDrawer.mm:146)
8 MyApp 0x0000fb72 -[STGameController playerToAct:] (STGameController.mm:940)
9 MyApp 0x00015b16 -[STGame playerToAct:] (STGame.mm:218)
10 MyApp 0x00018c0e -[STGameClient processMessage:arg:argLen:] (STGameClient.mm:461)
11 MyApp 0x00017520 -[STGameClient dataReceived:] (STGameClient.mm:150)
12 MyApp 0x0003a02c -[STLocalConnClient(STPrivate) dataReceivedFromServerCb:] (STLocalConnClient.mm:115)
13 Foundation 0x31b7593c __NSFireDelayedPerform + 408
14 CoreFoundation 0x34084a5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
15 CoreFoundation 0x340846c2 __CFRunLoopDoTimer + 358
16 CoreFoundation 0x34083298 __CFRunLoopRun + 1200
17 CoreFoundation 0x340064d6 CFRunLoopRunSpecific + 294
18 CoreFoundation 0x3400639e CFRunLoopRunInMode + 98
19 GraphicsServices 0x35c46fc6 GSEventRunModal + 150
20 UIKit 0x3514b73c UIApplicationMain + 1084
21 MyApp 0x000031c8 main (main.mm:113)
22 MyApp 0x00002e28 start + 32

这是缩短的代码:

-(UIButton*)createButtonWithTitle: (NSString*)title backgroundColor: (UIColor*)backgroundColor
{
...
UIButton* button = [[UIButton alloc] initWithFrame: CGRectZero];
button.titleLabel.font = [UIFont systemFontOfSize: (st::STUIDims::Self())->DrawerFontSize()];
button.titleLabel.adjustsFontSizeToFitWidth = YES;
[button setTitle: title forState: UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
...
return [button autorelease];

}

我已经看到至少 4 次崩溃来自 button.titleLabel.font 行和一次来自 button.titleLabel.adjustsFontSizeToFitWidth (后者因 -[ CALayer pointSize]: 无法识别的选择器发送到实例).

我认为这是一个内存问题,所以我在模拟器下使用 Valgrind 运行应用程序,包括发布和调试版本,但没有任何结果。它在 Apple 的库中找到了一堆东西,但在我的代码中什么也没有。并且崩溃在分配后立即发生。它怎么会腐败得这么快?

我不确定下一步该做什么。非常欢迎任何建议。

编辑:这是对 adjustsFontSizeToFitWidth 的放大:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0

Last Exception Backtrace:
0 CoreFoundation 0x33a888bf __exceptionPreprocess + 163
1 libobjc.A.dylib 0x351a41e5 objc_exception_throw + 33
2 CoreFoundation 0x33a8bacb -[NSObject doesNotRecognizeSelector:] + 175
3 CoreFoundation 0x33a8a945 ___forwarding___ + 301
4 CoreFoundation 0x339e5680 _CF_forwarding_prep_0 + 48
5 UIKit 0x34b84107 -[UILabel setAdjustsFontSizeToFitWidth:] + 279
6 MyApp 0x0003b7e4 -[STDrawer createButtonWithTitle:backgroundColor:] (STDrawer.mm:288)
7 MyApp 0x0003b4a0 -[STDrawer displayActionButtonsWithTitlesArray:] (STDrawer.mm:184)
8 MyApp 0x0003b364 -[STDrawer displayActionButtonsWithTitles:] (STDrawer.mm:147)
9 MyApp 0x00014ba8 -[STGameController playerToAct:] (STGameController.mm:943)
10 MyApp 0x0001c0bc -[STGame playerToAct:] (STGame.mm:219)
11 MyApp 0x0001fa98 -[STGameClient processMessage:arg:argLen:] (STGameClient.mm:461)
12 MyApp 0x000213b4 -[STGameClient dataReceived:] (STGameClient.mm:151)
13 MyApp 0x00050c7c -[STLocalConnClient(STPrivate) dataReceivedFromServerCb:] (STLocalConnClient.mm:116)
14 Foundation 0x3154d943 __NSFireDelayedPerform + 415
15 CoreFoundation 0x33a5ca63 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
16 CoreFoundation 0x33a5c6c9 __CFRunLoopDoTimer + 365
17 CoreFoundation 0x33a5b29f __CFRunLoopRun + 1207
18 CoreFoundation 0x339de4dd CFRunLoopRunSpecific + 301
19 CoreFoundation 0x339de3a5 CFRunLoopRunInMode + 105
20 GraphicsServices 0x3561efcd GSEventRunModal + 157
21 UIKit 0x34b23743 UIApplicationMain + 1091
22 MyApp 0x000031f8 main (main.mm:121)
23 MyApp 0x00002c90 start + 40

最佳答案

我遇到了同样的问题,结果是我不小心

[self.button setImage:iconImageName forState:UIControlStateNormal];

使用 NSString 而不是 UIImage 设置图像

关于iphone - 奇怪的 iOS 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9318377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com