Note that there are some explanatory texts on larger screens.

plurals
  1. PODebugging EXC_BAD_ACCESS from a NSString
    primarykey
    data
    text
    <p>I had a EXC_BAD_ACCESS message in my console. I read about the environment variables NSZombieEnabled and MallocStackLoggingNoCompact on <a href="http://coderslike.us/2009/05/05/finding-freeddeallocated-instances-of-objects/" rel="noreferrer">this site</a>. I created my environment variables: <strong>NSZombieEnabled = YES</strong> and <strong>MallocStackLoggingNoCompact = 1</strong>. In the console, I saw</p> <blockquote> <p>2010-03-01 19:13:46.924 CruzNomad[7952:207] *** -[CFString stringByAddingPercentEscapesUsingEncoding:]: message sent to deallocated instance 0x58448e0</p> </blockquote> <p>Then at the (gdb) prompt, I did <strong>info malloc-history 0x58448e0</strong>, which gave me:</p> <pre><code>Alloc: Block address: 0x058448e0 length: 64 Stack - pthread: 0xa0b33500 number of frames: 25 0: 0x98e089bc in malloc_zone_malloc 1: 0x21516aa in _CFRuntimeCreateInstance 2: 0x2152bf8 in __CFStringCreateImmutableFunnel3 3: 0x21567d9 in CFStringCreateCopy 4: 0x21742fc in _CFStringCreateWithFormatAndArgumentsAux 5: 0xdb546 in -[NSPlaceholderString initWithFormat:locale:arguments:] 6: 0xdb4d8 in +[NSString stringWithFormat:] 7: 0x23aa3 in -[BuisnessCardViewController viewDidLoad] at /Users/.../Classes/BuisnessCardViewController.m:85 8: 0x3d6796 in -[UIViewController view] 9: 0x347b4 in -[gm_menuViewController btn5_Pressed:] at /Users/.../Classes/menuViewController.m:535 10: 0x357459 in -[UIApplication sendAction:to:from:forEvent:] 11: 0x3baba2 in -[UIControl sendAction:to:forEvent:] 12: 0x3bcdc3 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] 13: 0x3bbb0f in -[UIControl touchesEnded:withEvent:] 14: 0x370e33 in -[UIWindow _sendTouchesForEvent:] 15: 0x35a81c in -[UIApplication sendEvent:] 16: 0x3610b5 in _UIApplicationHandleEvent 17: 0x2984ed1 in PurpleEventCallback 18: 0x2197b80 in CFRunLoopRunSpecific 19: 0x2196c48 in CFRunLoopRunInMode 20: 0x298378d in GSEventRunModal 21: 0x2983852 in GSEventRun 22: 0x362003 in UIApplicationMain 23: 0x2c8c in main at /Users/.../source/main.m:14 24: 0x2bfa in start </code></pre> <p>Line 7 says the problem was in line 85 of BuisnessCardViewController.m. That line is here:</p> <pre><code>fullAddress = [NSString stringWithFormat:@"%@ %@", fullAddress, myString]; </code></pre> <p>I'm appending the contents of <strong>fullAddress</strong> and <strong>myString</strong> and storing it back in <strong>fullAddress</strong>.</p> <p>If I'm interpreting this correctly, it appears that after this line, <strong>fullAddress</strong> is deallocated. When I drop a breakpoint and hover over the variable, its value says "out of scope."</p> <p><strong>fullAddress</strong> works later in this method. I use it to send to send to Google for reverse geocoding in line 164 of the same method.</p> <pre><code>NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&amp;output=csv", [fullAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; </code></pre> <p>Even here, it says "out of scope." I'm stumped...any advice??</p> <p>Thanks!</p> <p>Thomas</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload