Note that there are some explanatory texts on larger screens.

plurals
  1. POEXC_BAD_ACCESS, but with no zombies, and not in debug build configuration
    primarykey
    data
    text
    <p>This is driving me nuts. I just uploaded my first app to the App Store for the first time, and of course, now my app is exploding left and right. When I build with release build configuration, I randomly get an <code>EXC_BAD_ACCESS</code> after banging on the app for some variable amount of time. I turned Zombies back on, but the problem doesn't appear to be over-releasing a variable, as I don't get a message about sending a message to a released variable. </p> <p>The error does always appear in the same spot in my code. It looks like I'm trying to retain a variable that hasn't been initialized properly. I haven't the slightest idea how I could be doing that. </p> <p>But here's the weird thing: if I build in debug release configuration, IT NEVER CRASHES. I can bang on the thing all day long, and it's rock solid. I build with Release configuration, and it gets all intermittently crashy.</p> <p>Looking at the Build settings in the two configurations, there aren't that many differences. In debug, the GCC 4.0 Optimization level is "None", while in Release, it's "Fastest, Smallest." If I switch the optimization level in Release to "None," the app behaves itself. Does anyone have a clue what I should be looking for to fix this? Alternately, how many bad things happen if I Distribute with No optimization?</p> <p><strong>UPDATE:</strong></p> <p>Dang! I really need a magic debug tool for memory errors. I've been working this problem for the last day or so. I added an <code>exercise</code> method that would reliably generate a crash and started looking for the area of code that was causing it. </p> <p>The app would usually crash the 3rd-5th time I performed one particular type of operation. The only thing that was different about that type of operation was the value I returned from an accessory method. The accessory method generally returned <code>NSDecimalNumber</code>s with values of 0-3, but there was one special case when I was returning an <code>NSDecimalNumber</code> with a non-integer value. I would test the result of the accessory method looking for the non-integer value. I changed the special case to return an <code>NSDecimalNumber</code> with a value of -1 instead of the non-integer value, and I can no longer make the app crash.</p> <p>Basically, the only change I made was switching from <code>[[NSNumber numberWithDouble:num] decimalValue]</code> --> crash to <code>[[NSNumber numberWithInteger:num] decimalValue]</code> --> no crash</p> <p>It's a little but more complicated than that, but not much.</p> <p>Now, I'm happy that the app no longer crashes but the change I made does not fill me with confidence, as the old bits of code did not appear to be "broken" in any way. So, while my app doesn't crash anymore, it's not because I "fixed" it, I just changed some random thing and now it works. 8^(</p> <p><strong>UPDATE:</strong></p> <p>Debugger does not spit out a stack trace as it usually does when a program crashes. When it crashes, the debug console outputs the following:</p> <p>Loading program into debugger…</p> <p>[... copyright stuff...]</p> <pre><code>This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found). warning: Unable to read symbols from "UIKit" (not yet mapped into memory). warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found). warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory). Program loaded. sharedlibrary apply-load-rules all Attaching to program: `/Users/...', process 10066. Re-enabling shared library breakpoint 1 Cannot access memory at address 0x4 Cannot access memory at address 0x4 (gdb) </code></pre>
    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. COYou should look at your stack trace. What is actually crashing? The fact that changing an NSNumber leads to crashing suggests you may be over-releasing an NSNumber somewhere. NSNumbers are cached by the class; if you over-release one, you can crash on a completely different object that represents the same number. I've seen code that worked when a value was 2 but failed when it was 4 because the NSNumber for "4" had been over-released elsewhere in the system.
      singulars
    2. COI have had some problems debugging this issue. For reasons I do not understand, neither the debugger nor Instruments give me the kind of information I expect. Usually when the app crashes, the debugger just shows the main execution thread, with no detail about who called the method that caused the crash. Perhaps this is because the problem only manifests itself when the compiler is optimizing code, so the debugger has a harder time mapping source to object code. I'm sure it also doesn't help that my debugging chops are still a bit fundamental. As always, I appreciate your assistance.
      singulars
    3. COStill, you should post the stack trace (particularly the top few frames). Even if it includes none of your code, it can give a lot of information about where the problem comes from. In Cocoa, you are often asking for things to be run on your behalf at a later time. -autorelease is a very common example of this. When that "later time" crashes, none of "your code" will be in the stack, but it's still due to a bug in your code.
      singulars
 

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