Objective c -[NSResponder\u tryRetain]崩溃
我收到了来自用户的崩溃。这一次:Objective c -[NSResponder\u tryRetain]崩溃,objective-c,macos,memory-management,appkit,macos-catalina,Objective C,Macos,Memory Management,Appkit,Macos Catalina,我收到了来自用户的崩溃。这一次: Crashed Thread: 0 Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Illegal instruction: 4 Termi
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [79055]
Thread 0 Crashed:
0 com.apple.AppKit 0x00007fff30cc820a -[NSResponder _tryRetain] + 92
1 libobjc.A.dylib 0x00007fff693a1e1d objc_loadWeakRetained + 351
2 libobjc.A.dylib 0x00007fff693a3adc objc_loadWeak + 15
3 com.apple.AppKit 0x00007fff3075605a -[NSTableRowData ensureGroupRowIndexes] + 256
4 com.apple.AppKit 0x00007fff306e8161 -[NSTableView _isGroupRow:] + 106
5 com.apple.AppKit 0x00007fff30807219 -[NSTableView _sendDelegateHeightOfRow:] + 144
6 com.apple.AppKit 0x00007fff307f01cb -[NSTableView _safeSendDelegateHeightOfRow:] + 79
7 com.apple.AppKit 0x00007fff307f00f7 -[NSTableView _uncachedRectHeightOfRow:] + 274
8 com.apple.AppKit 0x00007fff307efe8c -[_NSTableRowHeightStorage _cacheRowHeights] + 52
9 com.apple.AppKit 0x00007fff3068a77d -[_NSTableRowHeightStorage _ensureRowHeights] + 57
10 com.apple.AppKit 0x00007fff3068a6cf -[_NSTableRowHeightStorage computeTableHeightForNumberOfRows:] + 80
11 com.apple.AppKit 0x00007fff30689b93 -[NSTableView _minimumFrameSize] + 73
12 com.apple.AppKit 0x00007fff3068918c -[NSTableView tile] + 285
13 com.apple.AppKit 0x00007fff306b014e -[NSTableView bounds] + 100
14 com.apple.AppKit 0x00007fff3065d920 -[NSView(NSInternal) _setLayerNeedsDisplayInViewRect:] + 171
15 com.apple.AppKit 0x00007fff306136b5 -[NSView setNeedsDisplayInRect:] + 767
16 com.apple.AppKit 0x00007fff30682a18 -[NSTableView _tileAndRedisplayAll] + 217
17 com.apple.CoreFoundation 0x00007fff3342c35f __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
18 com.apple.CoreFoundation 0x00007fff334bcc73 ___CFXRegistrationPost1_block_invoke + 63
19 com.apple.CoreFoundation 0x00007fff334bc308 _CFXRegistrationPost1 + 372
20 com.apple.CoreFoundation 0x00007fff334349be ___CFXNotificationPost_block_invoke + 97
21 com.apple.CoreFoundation 0x00007fff3339cce2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1575
22 com.apple.CoreFoundation 0x00007fff3339c172 _CFXNotificationPost + 1351
23 com.apple.Foundation 0x00007fff35a6336b -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
My App Code
而这个(来自另一个用户):
下面的消息让我乍一看很害怕。
特定于应用程序的信息:NSResponder中的Refcount溢出或
子类。太多不平衡的保留
最后,我成功地将崩溃复制到测试项目中:
@implementation AppDelegate
NSString * const SIFTFilePresentationViewIdentifier = @"sift:file presentation";
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self registerCells];// < - - - Commenting only this line fixes the issue.
self.outlineView.delegate = self;
self.outlineView.dataSource = self;
}
- (void)registerCells {
NSNib *nib = [[NSNib alloc] initWithNibNamed:@"SIFTFileView" bundle:nil];
[self.outlineView registerNib:nib forIdentifier:SIFTFilePresentationViewIdentifier];
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
if (item == nil) {
//Works fine:
//10.14.5 (18F132)
//MacBook Pro (15-inch, 2017)
//Crashes:
//10.15.1 (19B88)
//MacBook Pro (15-inch, 2018)
//2^25 = 33554432
return 33560000;
} else {
return 0;
}
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
if (item == nil) {
return @"321";
} else {
return nil;
}
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
return item == nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {// < - - - Commenting only this method fixes the issue.
return item == nil;
}
@end
@实现AppDelegate
NSString*const SIFTFilePresentationViewIdentifier=@“sift:文件表示”;
-(无效)ApplicationIDFinishLaunching:(NSNotification*)通知{
[self registerCells];//<--仅对这一行进行注释即可解决问题。
self.outlineView.delegate=self;
self.outlineView.dataSource=self;
}
-(作废)登记单元{
NSNib*nib=[[NSNib alloc]initWithNibNamed:@“SIFTFileView”bundle:nil];
[self.outlineView注册表nb:nib for identifier:SIFTFilePresentationViewIdentifier];
}
-(NSInteger)大纲视图:(NSOutlineView*)大纲视图儿童雷诺数项目:(id)项目{
如果(项目==零){
//工作正常:
//10.14.5(18F132)
//MacBook Pro(15英寸,2017年)
//崩溃:
//10.15.1(19B88)
//MacBook Pro(15英寸,2018年)
//2^25 = 33554432
返回33560000;
}否则{
返回0;
}
}
-(id)大纲视图:(NSOutlineView*)大纲视图子项:(NSInteger)项的索引:(id)项{
如果(项目==零){
返回@“321”;
}否则{
返回零;
}
}
-(BOOL)大纲视图:(NSOutlineView*)大纲视图可扩展:(id)项{
退货项目==零;
}
-(BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item{/<--仅注释此方法可修复此问题。
退货项目==零;
}
@结束
项目复制问题:
网络上的一些相关讨论:
@implementation AppDelegate
NSString * const SIFTFilePresentationViewIdentifier = @"sift:file presentation";
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self registerCells];// < - - - Commenting only this line fixes the issue.
self.outlineView.delegate = self;
self.outlineView.dataSource = self;
}
- (void)registerCells {
NSNib *nib = [[NSNib alloc] initWithNibNamed:@"SIFTFileView" bundle:nil];
[self.outlineView registerNib:nib forIdentifier:SIFTFilePresentationViewIdentifier];
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
if (item == nil) {
//Works fine:
//10.14.5 (18F132)
//MacBook Pro (15-inch, 2017)
//Crashes:
//10.15.1 (19B88)
//MacBook Pro (15-inch, 2018)
//2^25 = 33554432
return 33560000;
} else {
return 0;
}
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
if (item == nil) {
return @"321";
} else {
return nil;
}
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
return item == nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {// < - - - Commenting only this method fixes the issue.
return item == nil;
}
@end
NSParagraphStyle有一个19位的内联保留计数,没有溢出
保护(即,如果您也保留了它,它将被错误地解除分配
很多,然后称为一些释放)。这架飞机偶尔坠毁
Xcode(rdar://16008112)
我在LWJGL代码中看不到任何内存管理
这将导致溢出。因此,这次坠机事件似乎很严重
源自第一响应者方法内部。如果没有
发生在以前版本的MacOS中,我猜它可能是一个操作系统
bug或该方法工作方式行为的某种变化
我不明白为什么会这样,我们只是
要求NSTextView滚动自身
我确实注意到在坠机报告中有一个Refcount的信息文本
NSResponder或子类中存在溢出。太多不平衡的保留-
@a你认为这个积木应该从一个弱的角度起作用吗
提到自我?我很难想象这很重要,因为我们
记录了很多东西,我不相信我们见过
这次撞车之前
操作系统版本:Mac OS X 10.15.1(19B88)
我认为这是NSTableView的一个内部缺陷。如果你有任何想法,请告诉我。 < P>我认为它是NestLabVIEW内部错误。
在我的例子中,只有以下方法可以解决这个问题
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {
return item == nil;
}
因此,我为NSTableViewDelegate创建了两个对象,分别使用outlineView:isGroupItem:method和不使用它。我刚才代理给“上一个”委托的所有其他调用
- (void)updateInterfaceOfOutlineView {
NSOutlineView *outlineView = self.outlineView;
for (NSUInteger rowIndex = 0; rowIndex < outlineView.numberOfRows; rowIndex++) {
@autoreleasepool {//Adding this autoreleasepool also increased the amount of possible rows in table.
NSView *itemView = [outlineView viewAtColumn:0 row:rowIndex makeIfNecessary:NO];
if(itemView && [itemView respondsToSelector:@selector(updateInterface)]) {
[(id<SelectedItemView>)itemView updateInterface];
}
}
}
}
-(void)更新OutlineView的接口{
NSOutlineView*outlineView=self.outlineView;
对于(整数rowIndex=0;rowIndex
遗留代码。。。不要对它极为挑剔。 < P>我认为它是NestLabVIEW内部错误。
在我的例子中,只有以下方法可以解决这个问题
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item {
return item == nil;
}
因此,我为NSTableViewDelegate创建了两个对象,分别使用outlineView:isGroupItem:method和不使用它。我刚才代理给“上一个”委托的所有其他调用
- (void)updateInterfaceOfOutlineView {
NSOutlineView *outlineView = self.outlineView;
for (NSUInteger rowIndex = 0; rowIndex < outlineView.numberOfRows; rowIndex++) {
@autoreleasepool {//Adding this autoreleasepool also increased the amount of possible rows in table.
NSView *itemView = [outlineView viewAtColumn:0 row:rowIndex makeIfNecessary:NO];
if(itemView && [itemView respondsToSelector:@selector(updateInterface)]) {
[(id<SelectedItemView>)itemView updateInterface];
}
}
}
}
-(void)更新OutlineView的接口{
NSOutlineView*outlineView=self.outlineView;
对于(整数rowIndex=0;rowIndex
遗留代码。。。不要太挑剔。显然,您在表视图中保留了一些对象,这是过度的。你能发布一些你是如何实现它的代码吗?如果没有这些,就不可能帮助您。我已经在其他项目中添加了一些细节和类似的问题(有一些代码)。如果您知道问题的原因,请告诉我们。感谢您的关注。
objc\u loadWeak
是在对表视图的弱引用上调用的。请告诉我们关于表视图的情况,它是如何使用和实现的?您是否尝试过Xcode的静态分析器和诊断工具?是否使用自定义NSView填充NSTableView?此外,崩溃似乎发生在解除分配这些NSView时,而崩溃发生在NSTableView发布后想要引用它们时。您是否可以检查在用户使用此类视图填充表后关闭应用程序时是否会发生这种情况?此外,您使用什么样的模型来存储用于填充表的数据?@Willeke,非常感谢您提供的简单示例