"Program receive signal: EXC_BAD_ACCESS" - how to determine the line in which it was called?

How can I most easily find the point in my code where this one starts (ie, "Program Receive Signal: EXC_BAD_ACCESS")?

When I get this and I look in the console, I do not see any additional information, such as a stack trace in this case. I know that I can put breakpoints through the code and try to go through to find, however, if there is a way to more easily find out without a lot of breakpoints and go through it would be great.

EDIT 1 - Re-typing backtrace in (re this answer), I see it that doesn't seem to quite emphasize the meaning of 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 () 
+4
source share
4 answers

Try using NSZombies in tools. There is an Apple WWDC video on how to use it. This should help you determine where it comes from.

+4
source

NSZombieEnabled is likely to help you find the most re-released bugs. From CocoaDev :

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

For particularly unpleasant cases (unpleasant over-autorelease error in my case), some additional flags, such as NSDebugEnabled, MallocStackLogging and MallocStackLoggingNoCompact, will help you examine the save / release history for any variable. A tutorial on their use can be found here http://www.cocoadev.com/index.pl?DebuggingAutorelease

+5
source

Use the backtrace GDB command (type "backtrace" in the console). This will print the entire stack until it crashes.

More info here

+2
source

There are several things you can do to troubleshoot memory issues.

  • In some cases, you can use the debugger. Command + Shift + Y

  • You can use NSZombieEnabled .

  • You can use the "Build and analyze" in the Build menu.

+1
source

Source: https://habr.com/ru/post/1341567/


All Articles