EXC_BAD_ACCESS (code=2) when NSTextField in NSOutlineView has a connected IBOutlet action

I'm transitioning one of my projects from using .xib files to a single .storyboard file, and this one issue is driving me crazy. It seems to happen only in the project version with the storyboard. Every time I launch the app, the EXC_BAD_ACCESS error happens where the AppDelegate is declared. I could isolate the problem which can now be reproduced every second or third time when launching the following sample project: https://www.icloud.com/iclouddrive/0Vx_ZOrGuD7U0S9u_8dJz-_0A#problem
It seems that when removing the connection from the text field in the outline view to its action textFieldAction in ViewController, the crash doesn't happen anymore. How is this possible?
I loaded your app and ran with XCode 12GM / MacOS 10.15.6.

It crashes systematically.

I once succeeded to run with XCode 11.6, and it seemed to work OK when you quit with Quit but crash after an XCode Stop.
  • I added in AppDelegate:

Code Block
func applicationDidFinishLaunching(_ notification: Notification) {
print("launched")
}
  • And it worked.

  • I commented applicationDidFinishLaunching out, then app launched but crashed after a few seconds

  • I repeated several times (uncommenting applicationDidFinishLaunching, then commenting out again), always the same.

  • If I comment out only the print("launched"), it crashes as well.


I changed the value from 5 to 3 in:
Code Block
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
return item == nil ? 5 : 0
}

And it crashed.
But after disabling IBAction, does not crash anymore.

So I disabled IBAction and removed didFinishLaunching:
No crash effectively.

So, there may be some memory management issue, like zombie. Requires more investigation.

Note I once got the following error log (but not causing crash):

2020-09-25 19:24:19.778052+0200 problem[53542:4126339] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x60000212c0a0 V:|-(5)-[NSTextField:0x101817f30] (active, names: filename:0x101818270, '|':filename:0x101818270 )>",
"<NSLayoutConstraint:0x60000212c0f0 V:[NSTextField:0x101817f30]-(57)-| (active, names: filename:0x101818270, '|':filename:0x101818270 )>",
"<NSLayoutConstraint:0x60000212c550 'NSView-Encapsulated-Layout-Height' filename.height == 17 (active, names: filename:0x101818270 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000212c0f0 V:[NSTextField:0x101817f30]-(57)-| (active, names: filename:0x101818270, '|':filename:0x101818270 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUTCONSTRAINTSNOTSATISFIABLE to catch this in the debugger.
2020-09-25 19:24:19.779542+0200 problem[53542:4126339] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x60000212ca00 V:|-(5)-[NSTextField:0x10181d020] (active, names: filename:0x10181d360, '|':filename:0x10181d360 )>",
"<NSLayoutConstraint:0x60000212ca50 V:[NSTextField:0x10181d020]-(57)-| (active, names: filename:0x10181d360, '|':filename:0x10181d360 )>",
"<NSLayoutConstraint:0x60000212cd70 'NSView-Encapsulated-Layout-Height' filename.height == 17 (active, names: filename:0x10181d360 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000212ca50 V:[NSTextField:0x10181d020]-(57)-| (active, names: filename:0x10181d360, '|':filename:0x10181d360 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT
CONSTRAINTSNOTSATISFIABLE to catch this in the debugger.
2020-09-25 19:24:19.780800+0200 problem[53542:4126339] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x60000212d1d0 V:|-(5)-[NSTextField:0x101821040] (active, names: filename:0x101821380, '|':filename:0x101821380 )>",
"<NSLayoutConstraint:0x60000212d220 V:[NSTextField:0x101821040]-(57)-| (active, names: filename:0x101821380, '|':filename:0x101821380 )>",
"<NSLayoutConstraint:0x60000212d540 'NSView-Encapsulated-Layout-Height' filename.height == 17 (active, names: filename:0x101821380 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000212d220 V:[NSTextField:0x101821040]-(57)-| (active, names: filename:0x101821380, '|':filename:0x101821380 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUTCONSTRAINTSNOTSATISFIABLE to catch this in the debugger.
2020-09-25 19:24:19.781907+0200 problem[53542:4126339] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x60000212d9a0 V:|-(5)-[NSTextField:0x101823c50] (active, names: filename:0x101823f90, '|':filename:0x101823f90 )>",
"<NSLayoutConstraint:0x60000212d9f0 V:[NSTextField:0x101823c50]-(57)-| (active, names: filename:0x101823f90, '|':filename:0x101823f90 )>",
"<NSLayoutConstraint:0x60000212dd10 'NSView-Encapsulated-Layout-Height' filename.height == 17 (active, names: filename:0x101823f90 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60000212d9f0 V:[NSTextField:0x101823c50]-(57)-| (active, names: filename:0x101823f90, '|':filename:0x101823f90 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT
CONSTRAINTSNOTSATISFIABLE to catch this in the debugger.


Thanks for your reply. I already tried investigating with zombies turned on and even using Instruments, but they were of no help.
So, for the time being, may add appDidFinishLauncing to your app.
And file a bug report with the sample project (don't forget to attach all the tests that were done).

Good luck.

this one issue is driving me crazy ~ tried investigating 


You might try burning a support ticket w/DTS via the Member Center to see if they can shed light - they will need a buildable project that demos the issue...

Good luck.

EXC_BAD_ACCESS (code=2) when NSTextField in NSOutlineView has a connected IBOutlet action
 
 
Q