macOS 10.13 EXEC_BAD_ACCESS 子类化 NSTableView 或 NSScrollView 导致 [英] macOS 10.13 EXEC_BAD_ACCESS caused by subclassing NSTableView or NSScrollView

查看:69
本文介绍了macOS 10.13 EXEC_BAD_ACCESS 子类化 NSTableView 或 NSScrollView 导致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个相当奇怪的问题.将一些 NSView、NSTableView 和 NSScrollView 子类化为特定的.

I'm facing a rather odd problem. With subclassing some NSViews, NSTableView and NSScrollView to be specific.

情况:我正在为 macOS 开发一个相当古老(大约 7 年)的项目.代码库大约有 50% 的 objc 和 50% 的 swift 3.2,并使用 XIB 文件作为各个视图.该应用程序在 10.10 - 10.12 上运行流畅,但在 10.13 上几乎立即崩溃.

Situation: I'm working on a quite old (ca. 7 year) project for macOS. The codebase is about 50% objc and 50% swift 3.2 and uses XIB files for the individual views. The application runs smoothly on 10.10 - 10.12 but it crashes on 10.13 pretty much instantly.

回溯显示以下内容:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00007fff50490b05 Foundation`_NSKVONotifyingCreateInfoWithOriginalClass + 177
frame #1: 0x00007fff50490a35 Foundation`_NSKeyValueContainerClassGetNotifyingInfo + 59
frame #2: 0x00007fff504908c4 Foundation`-[NSKeyValueUnnestedProperty _isaForAutonotifying] + 75
frame #3: 0x00007fff5049075f Foundation`-[NSKeyValueUnnestedProperty isaForAutonotifying] + 75
frame #4: 0x00007fff5048f9fb Foundation`-[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] + 490
frame #5: 0x00007fff5048e7c9 Foundation`-[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 103
frame #6: 0x00007fff504da865 Foundation`-[NSKeyValueNestedProperty object:withObservance:didChangeValueForKeyOrKeys:recurse:forwardingValues:] + 411
frame #7: 0x00007fff504af6d8 Foundation`NSKeyValueDidChange + 179
frame #8: 0x00007fff505eb370 Foundation`NSKeyValueDidChangeWithPerThreadPendingNotifications + 132
frame #9: 0x00007fff4c2ac3a0 AppKit`-[NSView didChangeValueForKey:] + 93
frame #10: 0x00007fff504aff4d Foundation`NSKeyValueNotifyObserver + 350
frame #11: 0x00007fff504af800 Foundation`NSKeyValueDidChange + 475
frame #12: 0x00007fff505eb370 Foundation`NSKeyValueDidChangeWithPerThreadPendingNotifications + 132
frame #13: 0x00007fff4c2ac3a0 AppKit`-[NSView didChangeValueForKey:] + 93
frame #14: 0x00007fff4bbf6877 AppKit`-[NSScrollView _makeUnderTitlebarView] + 165
frame #15: 0x00007fff4b9e9eff AppKit`-[NSScrollView _updateStateOfUnderTitlebarView] + 327
frame #16: 0x00007fff4bae5ef1 AppKit`-[NSScrollView viewDidMoveToWindow] + 113
frame #17: 0x00007fff4b9e82b2 AppKit`-[NSView _setWindow:] + 2867
frame #18: 0x00007fff4b9efe9d AppKit`-[NSScrollView _setWindow:] + 500
frame #19: 0x00007fff4e3ef79f CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
frame #20: 0x00007fff4c2acfed AppKit`__21-[NSView _setWindow:]_block_invoke.604 + 141
frame #21: 0x00007fff504c9b4a Foundation`-[NSISEngine withBehaviors:performModifications:] + 131
frame #22: 0x00007fff4b9e602d AppKit`-[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] + 70
frame #23: 0x00007fff4b9e8203 AppKit`-[NSView _setWindow:] + 2692
frame #24: 0x00007fff4b9e52d5 AppKit`-[NSView addSubview:] + 257
frame #25: 0x00007fff4ba1e228 AppKit`-[NSFrameView addSubview:] + 44
frame #26: 0x00007fff4ba1e1ed AppKit`-[NSThemeFrame addSubview:] + 381
frame #27: 0x00007fff4ba1df1a AppKit`-[NSView addSubview:positioned:relativeTo:] + 214
frame #28: 0x00007fff4c2593bd AppKit`-[NSThemeFrame addSubview:positioned:relativeTo:] + 42
frame #29: 0x00007fff4ba1de37 AppKit`-[NSThemeFrame _addKnownSubview:positioned:relativeTo:] + 38
frame #30: 0x00007fff4ba43853 AppKit`-[NSWindow setContentView:] + 382
frame #31: 0x000000010007e8da MyApp`-[Document someContentViewItemSelected:](self=0x000060403b97eef0, _cmd="someContentViewItemSelected:", sender=0x0000604043fb0f60) at Document.m:230

回溯不是很有帮助(但也许我遗漏了一些东西),但是当新 ViewController 的视图被分配给窗口表的内容视图时会发生错误 self.windowForSheet.contentView = contentViewController.view.

The backtrace is not very helpful (but maybe I'm missing something), but the error occurs when the view of a new ViewController gets assigned to the window sheet's content view self.windowForSheet.contentView = contentViewController.view.

问题:该控制器的视图有一个 NSTableview,我将其子类化并将界面构建器中的类分配给表对象.如果我删除这个子类,一切正常.

Problem: The view of that controller has a NSTableview, which I subclassed and assigned the class in the interface builder to the table object. If I remove this subclass, everything works fine.

我的尝试:

我试图用完全空子类在 objc 和 swift 中重现该问题,并且两者都发生了问题并且应用程序崩溃具有完全相同的回溯.

I tried to reproduce the problem with completely empty subclasses written in objc and swift and with both, the problem occurs and the app crashes with the exact same backtrace.

我尝试使用带有视图控制器和子类 NSTableView 的 xib 创建一个新应用程序,它工作得很好!

I tried creating a new app utilising xib with the view controller and a subclassed NSTableView and it works just fine!

我尝试使用 Xcode 8.3.3(10.12 和 10.13)和 9.1(10.13)编译应用程序,结果应用程序显示相同的行为,在 10.12、10.11 上运行良好,但在 10.13 上崩溃.

I tried compiling the app with Xcode 8.3.3 (on 10.12 & 10.13)and 9.1 (on10.13) and the resulting apps show the same behaviour, working fine on 10.12, 10.11 but crashes on 10.13.

我认为这一切都与它是一个非常古老的项目有关,其中包含混合语言和过时的 xib 文件,但我无法指出具体细节.

I assume it all has to do with it being a very old project with mixed languages and outdated xib files, but I can't point my fingers at specifics.

问题:大家知道这可能是什么问题吗?在继承 NSTableView 或 NSScrollView 时遇到问题(顺便说一下,NSTableViewCell 子类工作得很好).

Question: Do you guys know what this problem could be? Have had problems with subclassing NSTableView or NSScrollView (NSTableViewCell subclasses work just fine by the way).

感谢您能给我的每一个帮助或意见.谢谢

I appreciate every help or input you can give me. Thank you

推荐答案

尝试更新旧框架.我遇到了 同样的问题Sparkle.从 1.8.0 更新到 1.18.1 解决了两个类似的错误.

Try to update old frameworks. I had the same problem with Sparkle. Updating from 1.8.0 to 1.18.1 have solved two similar bugs.

(大约 7 年)macOS 项目.

(ca. 7 year) project for macOS.

很遗憾,但还没有在 Sparkle 中找到修复崩溃的确切提交.我认为它介于 1.8.0 和 1.9.0 之间.如果您找到导致崩溃的确切代码行,请告诉我.

It's sad, but haven't found the exact commit in Sparkle that has fixed the crash. I think it is between versions 1.8.0 and 1.9.0. Please let me know if you find the exact line of code caused the crash.

这篇关于macOS 10.13 EXEC_BAD_ACCESS 子类化 NSTableView 或 NSScrollView 导致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆