Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Program received signal: EXC_BAD_ACCESS" - how to identify the line where this was triggered?

How can I most easily find out the point in my code where this (i.e. "Program received signal: EXC_BAD_ACCESS") is being triggered?

When I get this and I look in the console I don't see any additional info such as a stack trace in this case. I know I can put breakpoints through the code and try to step through to find, however if there is a way to more easily find out without lots of breakpoints and step through that would be great.

EDIT 1 - Re typing backtrace in (re this answer), I see this, which doesn't seem to quite highlight the point in my code?

(gdb) backtrace
#0  0x00fd7a63 in objc_msgSend ()
#1  0x06019780 in ?? ()
#2  0x0046cf16 in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] ()
#3  0x0046a9e7 in -[UITableViewRowData numberOfRows] ()
#4  0x003218c2 in -[UITableView noteNumberOfRowsChanged] ()
#5  0x0032e2b8 in -[UITableView reloadData] ()
#6  0x0032b470 in -[UITableView layoutSubviews] ()
#7  0x01d33451 in -[CALayer layoutSublayers] ()
#8  0x01d3317c in CALayerLayoutIfNeeded ()
#9  0x01d2c37c in CA::Context::commit_transaction ()
#10 0x01d2c0d0 in CA::Transaction::commit ()
#11 0x01d5c7d5 in CA::Transaction::observer_callback ()
#12 0x00e56fbb in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#13 0x00dec0e7 in __CFRunLoopDoObservers ()
#14 0x00db4bd7 in __CFRunLoopRun ()
#15 0x00db4240 in CFRunLoopRunSpecific ()
#16 0x00db4161 in CFRunLoopRunInMode ()
#17 0x017aa268 in GSEventRunModal ()
#18 0x017aa32d in GSEventRun ()
#19 0x002c342e in UIApplicationMain ()
like image 206
Greg Avatar asked Dec 17 '22 16:12

Greg


2 Answers

NSZombieEnabled will most likely help you find most over-released bugs. From CocoaDev:

Use in Xcode: Double-click an executable in the Executables group of your Xcode project. Click the Arguments tab. In the "Variables to be set in the environment:" section, make a variable called "NSZombieEnabled" and set its value to "YES".

For particularly nasty cases (a nasty over-autorelease bug in my case) some additional flags like NSDebugEnabled, MallocStackLogging, and MallocStackLoggingNoCompact will help you examine the retain/release history for any variable. Tutorial for how to use them can be found here http://www.cocoadev.com/index.pl?DebuggingAutorelease

like image 188
ACBurk Avatar answered May 16 '23 06:05

ACBurk


Try using NSZombies in Instruments. There is an Apple WWDC video on how to use it. That should help you identify where it is coming from.

like image 25
Ajay Avatar answered May 16 '23 04:05

Ajay