• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you?


  • Subject: Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you?
  • From: Scott Ellsworth <email@hidden>
  • Date: Tue, 11 Jul 2006 15:00:18 -0700


On Jul 11, 2006, at 2:15 PM, Sean McBride wrote:

On 2006-07-12 07:07, Chris Suter said:

I tried the same thing with an NSString, and with CFZombieLevel (1,
19, 5, and a few other values based on the tech note), and all I
got were bad access exceptions.

Just thought I'd point out that I think the numbers you used don't look quite right. The tech. note doesn't define what 5 would do; the table in the note uses bit numbers. From my understanding of the note, you'll get a crash for most settings of CFZombieLevel except for 8 (never free memory used to hold CF objects) and under certain circumstances 2 (when scribbling deallocated CF memory, don't scirbble object header (CFRuntimeBase)). I guess you'll get similar results to NSZombieEnabled by setting CFZombieLevel to 9 (although obviously you'll get a crash rather than an exception thrown, but that's just as good).

Ah, you're right! I think Scott's values were just no good.

Pilot error!

Thanks, all - having something that always crashes is quite useful.

FWIW, the '5' came from Aaron Hillegas' blog page, while the others were from my own imagination based on a quick, incorrect, hex conversion. Mea culpa.

Without CFZombieLevel, both these print twice:

	NSString*		str = [[NSString alloc] initWithFormat:@"hello"];
	NSLog (@"%@", str);
	[str release];
	NSLog (@"%@", str);

	CFStringRef		str = CFStringCreateWithFormat(0,0,CFSTR("hello"));
	CFShow(str);
	CFRelease(str);
	CFShow(str);

With CFZombieLevel=65553 both crash on the 2nd print attempt.

Does it produce a usable stack trace in the debugger when it dies? With:


	NSLog(@"Using toll free bridged zombie object");
	NSString * string = [[NSString alloc] initWithFormat:@"String hello"];
	[string release];
	int x = [string length];

(Or a call to stringByAppendingString on the zombie)

I get the following trackback:

#0	0x90a4e380 in objc_msgSend
#1	0x04e9e510 in ??
#2	0x93490ea0 in -[NSApplication sendAction:to:from:]
#3	0x93490df9 in -[NSControl sendAction:to:]
#4	0x93492fa9 in -[NSCell _sendActionFrom:]
#5	0x934a5775 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#6	0x934c329c in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#7	0x934c2b31 in -[NSControl mouseDown:]
#8	0x934804b7 in -[NSWindow sendEvent:]
#9	0x93472524 in -[NSApplication sendEvent:]
#10	0x9339d106 in -[NSApplication run]
#11	0x93391037 in NSApplicationMain
#12	0x00002838 in main at main.m:13

Trying the NSLog, the trace consists only of objc_msgSend.

Without the debug libraries, we go straight to a "EXC_BAD_ACCESS", while with them the message shows up a bit later.

So all is well.

Mostly well. Obviously, with an auto-crash, stepping through in the debugger works. It would save some time were there a way to get a usable stack trace in the debugger, so that the stepping could start in the right method.


(Not being difficult - I am trying to describe how one does this kind of debugging, and having it not produce a usable stack track makes it harder.)

Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Debugging: do CFZombieLevel and objc_exception_throw() work for you? (From: Scott Ellsworth <email@hidden>)
 >Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you? (From: Chris Suter <email@hidden>)
 >Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you? (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Selector Not Recognized
  • Next by Date: Re: Out-of-order Undos and NSTextField [SOLVED, well sort of]
  • Previous by thread: Re: Debugging: do CFZombieLevel and objc_exception_throw() work for you?
  • Next by thread: Data Model Design Q: Translation
  • Index(es):
    • Date
    • Thread