Foundation -[NSConcreteMapTable assign:key:value:isNew:] 崩溃:com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 在

Foundation -[NSConcreteMapTable assign:key:value:isNew:] Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at

我有一个崩溃只发生在 IOS 7,我无法重现它,但它发生了很多次。有人有答案或至少知道问题出在哪里吗? 我已经删除了所有关于 ios7 的警告,但崩溃仍然发生。 附上日志。

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x3b43c626 objc_msgSend + 5
1  Foundation                     0x315a9681 -[NSConcreteMapTable assign:key:value:isNew:] + 68
2  Foundation                     0x315a95fb -[NSConcreteMapTable setObject:forKey:] + 82
3  Foundation                     0x315ecaf7 -[NSISEngine setRowWithHead:body:] + 30
4  Foundation                     0x315ef5d1 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 388
5  Foundation                     0x315ed325 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 236
6  Foundation                     0x315efd9f -[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 226
7  Foundation                     0x315eb5fd -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 692
8  Foundation                     0x315eb23b -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 286
9  Foundation                     0x315e8f6d -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 232
10 Foundation                     0x315f47ed -[NSLayoutConstraint _addToEngine:] + 28
11 UIKit                          0x33591c55 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 332
12 Foundation                     0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
13 UIKit                          0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
14 UIKit                          0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
15 UIKit                          0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
16 Foundation                     0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
17 UIKit                          0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
18 UIKit                          0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
19 UIKit                          0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
20 Foundation                     0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
21 UIKit                          0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
22 UIKit                          0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
23 UIKit                          0x33591bbb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 178
24 Foundation                     0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
25 UIKit                          0x33591ad9 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 336
26 UIKit                          0x3349e20d -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 200
27 UIKit                          0x3349de33 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 82
28 Foundation                     0x315e8b2b -[NSISEngine withBehaviors:performModifications:] + 210
29 UIKit                          0x3349dcd3 -[UIView(Hierarchy) _postMovedFromSuperview:] + 298
30 UIKit                          0x334aaa4f -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1414
31 UIKit                          0x334aa4bf -[UIView(Hierarchy) addSubview:] + 30
32 UIKit                          0x3358bdb7 -[UITransitionView transition:fromView:toView:removeFromView:] + 978
33 UIKit                          0x335cbf3f -[UITransitionView transition:fromView:toView:] + 30
34 UIKit                          0x335cbf15 -[UITransitionView transition:toView:] + 104
35 UIKit                          0x335cb03b -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 1106
36 UIKit                          0x335cabdf -[UITabBarController transitionFromViewController:toViewController:] + 38
37 UIKit                          0x335caab7 -[UITabBarController _setSelectedViewController:] + 258
38 UIKit                          0x33694dd5 -[UITabBarController _tabBarItemClicked:] + 272
39 UIKit                          0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
40 UIKit                          0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
41 UIKit                          0x33694c8b -[UITabBar _sendAction:withEvent:] + 370
42 UIKit                          0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
43 UIKit                          0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
44 UIKit                          0x334d3fb1 -[UIControl sendAction:to:forEvent:] + 44
45 UIKit                          0x334bf717 -[UIControl _sendActionsForEvents:withEvent:] + 374
46 UIKit                          0x336949ab -[UITabBar(Static) _buttonUp:] + 118
47 UIKit                          0x334d4037 -[UIApplication sendAction:to:from:forEvent:] + 90
48 UIKit                          0x334d3fd7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
49 UIKit                          0x334d3fb1 -[UIControl sendAction:to:forEvent:] + 44
50 UIKit                          0x334bf717 -[UIControl _sendActionsForEvents:withEvent:] + 374
51 UIKit                          0x334d3a2f -[UIControl touchesEnded:withEvent:] + 590
52 UIKit                          0x334d3701 -[UIWindow _sendTouchesForEvent:] + 528
53 UIKit                          0x334ce6cb -[UIWindow sendEvent:] + 758
54 UIKit                          0x334a38cd -[UIApplication sendEvent:] + 196
55 UIKit                          0x334a1f77 _UIApplicationHandleEventQueue + 7102
56 CoreFoundation                 0x30c4d20b __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
57 CoreFoundation                 0x30c4c6db __CFRunLoopDoSources0 + 206
58 CoreFoundation                 0x30c4aecf __CFRunLoopRun + 622
59 CoreFoundation                 0x30bb5ebf CFRunLoopRunSpecific + 522
60 CoreFoundation                 0x30bb5ca3 CFRunLoopRunInMode + 106
61 GraphicsServices               0x35abb663 GSEventRunModal + 138
62 UIKit                          0x3350214d UIApplicationMain + 1136

我遇到了类似的崩溃,只是当我对在网络回调中创建的 UIView 执行 removeFromSuperview 时发生。 [NSISEngine withBehaviors:performModifications:] 是在 removeFromSuperview

之后开始出错的地方

例如。里面 handleReadStreamEvent

if (!CFReadStreamSetClient( inputStream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered | kCFStreamEventOpenCompleted
                           , handleReadStreamEvent, &context ) )

大多数情况下,似乎在此回调中创建的任何视图在从父视图中删除时都会崩溃。

每当我在回调中进行任何 UIView 更改时,我最终都会使用它。

- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;

在循环计时器回调中发生同样的情况

CFRunLoopAddTimer( CFRunLoopGetMain(), timeoutTimer, kCFRunLoopCommonModes);

我遇到了同样的问题。奇怪的是它只出现在3.5inch设备(ip4,ip4S),os7.x。在 ip5 上工作正常。

更新:我们的团队找到了根本原因。因为我们在代码中使用了这个动画

[UIView animateWithDuration:0.4f delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
                self.transform = CGAffineTransformMakeScale(sx,sy);
            } completion:^(BOOL finished) {
                self.hidden = !visible;
            }];

为了修复错误,如果 iOS <8.0

,我们会避免 运行 动画
 if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
        [UIView animateWithDuration:0.4f delay:0 usingSpringWithDamping:0.5f initialSpringVelocity:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
            self.transform = CGAffineTransformMakeScale(sx,sy);
        } completion:^(BOOL finished) {
            if (finished) {
                self.hidden = !visible;
            }
        }];
    } else {
        self.transform = CGAffineTransformMakeScale(sx,sy);
        self.hidden = !visible;
    }

希望对您有所帮助!

感谢您的回复。 我通过在弹出视图控制器之前移除键盘 (resignFirstResponder) 来解决它。

在那个屏幕上,我有 2 个文本字段,其中一个连接到键盘(inpuAccessoryView),另一个刚刚激活第一个(我正在开发聊天),弹出视图控制器时可能出了点问题。

希望这会对某人有所帮助。