Re: Crashing in NSTabView

2019-05-22 Thread Casey McDermott
Turning off ARC in one file helped track down the problem.  Thanks Daniel!

With breakpoints in retain and autorelease, it was possible to step through
the whole tab setup process.   Turns out that NSTabViewController's
addChildViewController calls didSelectTabViewItem before the tab is set up 
properly.

I'm not quite sure how that threw off reference counting, but it stopped
crashing after adding a  branch in didSelectTabViewItem to bypass the first 
call.

Thanks for all the suggestions!

Casey McDermott
Turtle Creek Software
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Daniel DeCovnick
In the Build Phases tab of the target, open compile sources and set the 
compiler flags for your subclass’s .m to -fno-objc-arc. 

Don’t forget that the signature for -release is -(oneway void)release, not just 
-(void)release :)

Daniel


> On May 22, 2019, at 12:13 PM, Carl Hoefs  
> wrote:
> 
> 
>> On May 22, 2019, at 11:31 AM, Daniel DeCovnick > > wrote:
>> 
>> You can always subclass, turn off ARC for that file, and override -release 
>> or -autorelease to breakpoint in.
> 
> How does one turn off ARC for a specific file?
> -Carl
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread James Walker

On 5/22/19 11:20 AM, Casey McDermott wrote:

  Instruments shows the child view controller being deallocated improperly 
after a tab switch.
Unfortunately it's either run the debugger or run Instruments, but not both.
So it doesn't help narrow down to when the release happens, exactly.

Instruments has an Allocations list that shows caller and stack trace for 
allocation of each object, but nothing
for release or deallocation.

If Apple views this list- adding release/dealloc info in 
Instruments-Allocations would by extremely useful.



In the Statistic / Allocation Summary list, find the class you want, 
select that row, and then click the little right arrow to the right of 
the name.  That will open a new list of specific instances of that 
class.  Then pick one of these rows, and again click the little right 
arrow icon.  You'll then see a log of retain/release/autorelease for 
that instance.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Carl Hoefs


> On May 22, 2019, at 11:31 AM, Daniel DeCovnick  wrote:
> 
> You can always subclass, turn off ARC for that file, and override -release or 
> -autorelease to breakpoint in.

How does one turn off ARC for a specific file?
-Carl

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Casey McDermott
 With current ARC, it's not allowed to override retain, release, autorelease or 
retaincount.
Too bad, because breakpoints there can really help when debugging lifetime 
issues.

Worst case, I guess we could go back to an earlier Xcode that allows them.
But that won't be fun.

Casey McDermott
Turtle Creek Software
 On Wednesday, May 22, 2019, 2:08:44 PM EDT, Markus Spoettl 
 wrote:  
 
 In the past, if the crash like that was reliably and not to complicated to 
recreate and I 
had no other choice, then overriding -autorelease and putting a breakpoint into 
that 
worked on some occasions. Be prepared to get a lot of hits though.

The object likely gets over-released by an auto-release sometime before the 
actual release 
causes the crash.

Best Regards
Markus

On 5/22/19 7:19 PM, Casey McDermott wrote:
>  Yes, we added a NSArray in the tab view controller with a strong ref to each 
>child view controller. That slows down the crash by one cycle,
> but doesn't provide any additional clues.
> 
> Is there a way for NSZombie to show when the object is released? AFAICT it 
> only kicks in on dealloc. We can see that happen already
> with a breakpoint.
> 
> The Allocations feature in Instruments looks promising. Is there a way to 
> limit the display to just one class? Otherwise it is WTMI.
> 
> Sorry for asking stupid questions on these tools, but Apple's docs are not 
> very good. Stack Overflow is often for old Xcode versions
> where everything is different. We are mostly C++ folks, where this kind of 
> problem is easily solved with a breakpoint in the destructor.
> 
> Thanks,
> 
> Casey McDermott
> Turtle Creek Software
>      On Wednesday, May 22, 2019, 11:43:30 AM EDT, Keary Suska 
> wrote:
>  
>  When you say "separate, strong reference to each tab view controller” do you 
>mean each child view controller that controls a single tab view item, or the 
>tab view controller as a whole? It is keeping string references to the 
>individual child view controllers that should solve your situation.
> 
> You may also want to check out Instrument’s zombies, which might better 
> pinpoint where the issue is ocurring.
> 
> HTH,
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
> 
>> On May 22, 2019, at 8:26 AM, Casey McDermott  wrote:
>>
>> Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs 
>> a few times, one of the NSTabViewItems would release
>> prematurely, causing a crash.  So we switched it to using a 
>> NSTabViewController.  Tab switching still crashes, but now it releases a
>> NSViewController prematurely.
>>
>> Nothing else in the code references tab items or tab controllers.  This is 
>> baffling. We can set a breakpoint on dealloc to see when it is deleted,
>> but can't breakpoint on release to see what releases it.  We build with 
>> latest Xcode but this has been going on with older ones also.
>>
>> We tried adding a separate, strong reference to each tab view controller.  
>> It still crashes, but it takes a few more tab switches before the controller 
>> is released.
>>
>> Any suggestions for what might be causing this?
>>
>> Casey McDermott
>> Turtle Creek Software
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com
>>
>> This email sent to cocoa-...@esoteritech.com
>    
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/ms_lists%40shiftoption.com
> 
> This email sent to ms_li...@shiftoption.com
> 


-- 
__
Markus Spoettl
  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Daniel DeCovnick
You can always subclass, turn off ARC for that file, and override -release or 
-autorelease to breakpoint in. I’ve done that on occasion with particularly 
tricky overrelease bugs (which actually turned out to be an under-autorelease 
bug in some non-ARC code).

Daniel

> On May 22, 2019, at 11:20 AM, Casey McDermott  wrote:
> 
> Instruments shows the child view controller being deallocated improperly 
> after a tab switch.
> Unfortunately it's either run the debugger or run Instruments, but not both.
> So it doesn't help narrow down to when the release happens, exactly.
> 
> Instruments has an Allocations list that shows caller and stack trace for 
> allocation of each object, but nothing
> for release or deallocation. 
> 
> If Apple views this list- adding release/dealloc info in 
> Instruments-Allocations would by extremely useful. 
> As would allowing - (void) release ( [super release]; } in code, so a 
> breakpoint can go there. 
> dealloc is too late to be useful.
> 
> Casey McDermott
> Turtle Creek Software
> 
> 
> On Wednesday, May 22, 2019, 1:23:57 PM EDT, Matt Jacobson 
>  wrote:  
> 
> 
> 
> 
> On May 22, 2019, at 1:19 PM, Casey McDermott  wrote:
> The Allocations feature in Instruments looks promising. Is there a way to 
> limit the display to just one class? Otherwise it is WTMI.
> 
> 
> Check out File → Recording Options…
> Matt  
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/danhd123%40mac.com
> 
> This email sent to danhd...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Casey McDermott
 Instruments shows the child view controller being deallocated improperly after 
a tab switch.
Unfortunately it's either run the debugger or run Instruments, but not both.
So it doesn't help narrow down to when the release happens, exactly.

Instruments has an Allocations list that shows caller and stack trace for 
allocation of each object, but nothing
for release or deallocation. 

If Apple views this list- adding release/dealloc info in 
Instruments-Allocations would by extremely useful. 
As would allowing - (void) release ( [super release]; } in code, so a 
breakpoint can go there. 
dealloc is too late to be useful.

Casey McDermott
Turtle Creek Software


 On Wednesday, May 22, 2019, 1:23:57 PM EDT, Matt Jacobson 
 wrote:  
 
 


On May 22, 2019, at 1:19 PM, Casey McDermott  wrote:
The Allocations feature in Instruments looks promising. Is there a way to limit 
the display to just one class? Otherwise it is WTMI.


Check out File → Recording Options…
Matt  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Markus Spoettl
In the past, if the crash like that was reliably and not to complicated to recreate and I 
had no other choice, then overriding -autorelease and putting a breakpoint into that 
worked on some occasions. Be prepared to get a lot of hits though.


The object likely gets over-released by an auto-release sometime before the actual release 
causes the crash.


Best Regards
Markus

On 5/22/19 7:19 PM, Casey McDermott wrote:

  Yes, we added a NSArray in the tab view controller with a strong ref to each 
child view controller. That slows down the crash by one cycle,
but doesn't provide any additional clues.

Is there a way for NSZombie to show when the object is released? AFAICT it only 
kicks in on dealloc. We can see that happen already
with a breakpoint.

The Allocations feature in Instruments looks promising. Is there a way to limit 
the display to just one class? Otherwise it is WTMI.

Sorry for asking stupid questions on these tools, but Apple's docs are not very 
good. Stack Overflow is often for old Xcode versions
where everything is different. We are mostly C++ folks, where this kind of 
problem is easily solved with a breakpoint in the destructor.

Thanks,

Casey McDermott
Turtle Creek Software
  On Wednesday, May 22, 2019, 11:43:30 AM EDT, Keary Suska 
 wrote:
  
  When you say "separate, strong reference to each tab view controller” do you mean each child view controller that controls a single tab view item, or the tab view controller as a whole? It is keeping string references to the individual child view controllers that should solve your situation.


You may also want to check out Instrument’s zombies, which might better 
pinpoint where the issue is ocurring.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


On May 22, 2019, at 8:26 AM, Casey McDermott  wrote:

Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs a 
few times, one of the NSTabViewItems would release
prematurely, causing a crash.  So we switched it to using a 
NSTabViewController.  Tab switching still crashes, but now it releases a
NSViewController prematurely.

Nothing else in the code references tab items or tab controllers.  This is 
baffling. We can set a breakpoint on dealloc to see when it is deleted,
but can't breakpoint on release to see what releases it.  We build with latest 
Xcode but this has been going on with older ones also.

We tried adding a separate, strong reference to each tab view controller.  It 
still crashes, but it takes a few more tab switches before the controller is 
released.

Any suggestions for what might be causing this?

Casey McDermott
Turtle Creek Software
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com

This email sent to cocoa-...@esoteritech.com
   
___


Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/ms_lists%40shiftoption.com

This email sent to ms_li...@shiftoption.com




--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Matt Jacobson


> On May 22, 2019, at 1:19 PM, Casey McDermott  wrote:
> 
> The Allocations feature in Instruments looks promising. Is there a way to 
> limit the display to just one class? Otherwise it is WTMI.

Check out File → Recording Options…

Matt
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Casey McDermott
 Yes, we added a NSArray in the tab view controller with a strong ref to each 
child view controller. That slows down the crash by one cycle,
but doesn't provide any additional clues.

Is there a way for NSZombie to show when the object is released? AFAICT it only 
kicks in on dealloc. We can see that happen already
with a breakpoint. 

The Allocations feature in Instruments looks promising. Is there a way to limit 
the display to just one class? Otherwise it is WTMI.

Sorry for asking stupid questions on these tools, but Apple's docs are not very 
good. Stack Overflow is often for old Xcode versions
where everything is different. We are mostly C++ folks, where this kind of 
problem is easily solved with a breakpoint in the destructor.

Thanks,

Casey McDermott
Turtle Creek Software
 On Wednesday, May 22, 2019, 11:43:30 AM EDT, Keary Suska 
 wrote:  
 
 When you say "separate, strong reference to each tab view controller” do you 
mean each child view controller that controls a single tab view item, or the 
tab view controller as a whole? It is keeping string references to the 
individual child view controllers that should solve your situation.

You may also want to check out Instrument’s zombies, which might better 
pinpoint where the issue is ocurring.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 22, 2019, at 8:26 AM, Casey McDermott  wrote:
> 
> Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs 
> a few times, one of the NSTabViewItems would release
> prematurely, causing a crash.  So we switched it to using a 
> NSTabViewController.  Tab switching still crashes, but now it releases a
> NSViewController prematurely.  
> 
> Nothing else in the code references tab items or tab controllers.  This is 
> baffling. We can set a breakpoint on dealloc to see when it is deleted, 
> but can't breakpoint on release to see what releases it.  We build with 
> latest Xcode but this has been going on with older ones also.
> 
> We tried adding a separate, strong reference to each tab view controller.  It 
> still crashes, but it takes a few more tab switches before the controller is 
> released.
> 
> Any suggestions for what might be causing this?
> 
> Casey McDermott
> Turtle Creek Software
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.com
  
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread Keary Suska
When you say "separate, strong reference to each tab view controller” do you 
mean each child view controller that controls a single tab view item, or the 
tab view controller as a whole? It is keeping string references to the 
individual child view controllers that should solve your situation.

You may also want to check out Instrument’s zombies, which might better 
pinpoint where the issue is ocurring.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On May 22, 2019, at 8:26 AM, Casey McDermott  wrote:
> 
> Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs 
> a few times, one of the NSTabViewItems would release
> prematurely, causing a crash.  So we switched it to using a 
> NSTabViewController.  Tab switching still crashes, but now it releases a
> NSViewController prematurely.  
> 
> Nothing else in the code references tab items or tab controllers.  This is 
> baffling. We can set a breakpoint on dealloc to see when it is deleted, 
> but can't breakpoint on release to see what releases it.  We build with 
> latest Xcode but this has been going on with older ones also.
> 
> We tried adding a separate, strong reference to each tab view controller.  It 
> still crashes, but it takes a few more tab switches before the controller is 
> released.
> 
> Any suggestions for what might be causing this?
> 
> Casey McDermott
> Turtle Creek Software
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoteritech.com
> 
> This email sent to cocoa-...@esoteritech.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Crashing in NSTabView

2019-05-22 Thread James Walker

On 5/22/19 7:26 AM, Casey McDermott wrote:

Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs a 
few times, one of the NSTabViewItems would release
prematurely, causing a crash.  So we switched it to using a 
NSTabViewController.  Tab switching still crashes, but now it releases a
NSViewController prematurely.

Nothing else in the code references tab items or tab controllers.  This is 
baffling. We can set a breakpoint on dealloc to see when it is deleted,
but can't breakpoint on release to see what releases it.  We build with latest 
Xcode but this has been going on with older ones also.

We tried adding a separate, strong reference to each tab view controller.  It 
still crashes, but it takes a few more tab switches before the controller is 
released.

Any suggestions for what might be causing this?


I don't know what would cause it, but I have some suggestions for how to 
investigate, if you haven't already done them:


1. Run the static analyzer.
2. Run using Address Sanitizer.
3. Use Instruments.  It can record all the retains and releases.  I 
think I'm thinking of the "leaks" instrument.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Crashing in NSTabView

2019-05-22 Thread Casey McDermott
Our Mac app adds tabs to a NSTabView programmatically.  After switching tabs a 
few times, one of the NSTabViewItems would release
prematurely, causing a crash.  So we switched it to using a 
NSTabViewController.  Tab switching still crashes, but now it releases a
NSViewController prematurely.  

Nothing else in the code references tab items or tab controllers.  This is 
baffling. We can set a breakpoint on dealloc to see when it is deleted, 
but can't breakpoint on release to see what releases it.  We build with latest 
Xcode but this has been going on with older ones also.

We tried adding a separate, strong reference to each tab view controller.  It 
still crashes, but it takes a few more tab switches before the controller is 
released.

Any suggestions for what might be causing this?

Casey McDermott
Turtle Creek Software
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com