• 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 strategy - exceptions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging strategy - exceptions


  • Subject: Re: Debugging strategy - exceptions
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 9 Jul 2008 06:59:28 -0500

On Jul 9, 2008, at 5:13 AM, Ruotger Skupin wrote:

this is more of an open discussion topic than a concrete question but hopefully someone has a good idea about this:

I got a bug report of a non-crash bug I cannot reproduce and where I do not even know where to start looking. The only hint is a line in the console.log:

*** -[NSCFDictionary initWithObjects:forKeys:count:]: attempt to insert nil value at objects[0] (key: NSFont)

So an exception got thrown for a pretty obvious reason, but where? Could be anywhere, even in WebKit (which we use). Is there any chance to get near the culprit without a stack trace (which I don't have)?

You will need to get a stack trace for any reasonable debugging.

I take it this is happening for a user but not for you, the developer? You could try to talk them through launching your program through gdb, although that would be a pain for you and them. It might entail them installing Xcode.

If the user is on Leopard, you could send them a DTrace one-liner that they could execute. You would use the "pid" provider to probe the objc_exception_throw function entry point and trace the stack. Something like:

sudo dtrace -n 'pid$target::objc_exception_throw:entry {ustack();}' -p `ps xww | grep /TextEdit | grep -v grep | sed -Ee 's/^ *([0-9]+).*/\1/'`

except using your application name instead of "TextEdit".


Even worse: There does not to be a way to switch off exceptions without switching off @synchronized() at the same time. That's not an option for the code in question.

You can't turn off exceptions, even if you do turn off @synchronized. Turning off @synchronized for your own code would prevent you from using @throw, but not from using -[NSException raise]. In any case, it doesn't change what the frameworks can do.


However, if you're willing to supply your user with a new version of your application (and it sounds like you are), you can use NSExceptionHandler. See <http://developer.apple.com/documentation/Cocoa/Conceptual/Exceptions/Tasks/ControllingAppResponse.html >.

Lastly, you should be familiar with TechNote 2124, Mac OS X Debugging Magic <http://developer.apple.com/technotes/tn2004/tn2124.html> if you aren't already.

Cheers,
Ken
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Debugging strategy - exceptions (From: Ruotger Skupin <email@hidden>)

  • Prev by Date: Re: How to indent in NSOutlineView?
  • Next by Date: how to get the status of network when the network is set disable.
  • Previous by thread: Re: Debugging strategy - exceptions
  • Next by thread: Re: Debugging strategy - exceptions
  • Index(es):
    • Date
    • Thread