• 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: How to debug GC related EXC_BAD_ACCESS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to debug GC related EXC_BAD_ACCESS


  • Subject: Re: How to debug GC related EXC_BAD_ACCESS
  • From: Bill Bumgarner <email@hidden>
  • Date: Tue, 05 May 2009 11:29:24 -0700

On Nov 24, 2008, at 11:45 AM, Nirias wrote:
I have a garbage collected application that runs (apparently) flawlessly
with a debug build. But with a release build it promptly fails with an
EXC_BAD_ACESS error. My guess is that somehow the GC is not seeing a clear
reference to some object(s) and is releasing them too soon.
Is there a recommended way to debug this? Maybe some way to log all
releases from the GC?

What does the crash look like? .... got backtrace?

Have you tried turning on MallocStackLogging and seeing what the allocation history of the object that died is?

This sounds like the optimizer is kicking in and changing the lifespan of a variable out from under you.

Might you possibly be using an interior pointer into something?

I.e.

{
    NSData *d = [.... get yer data here ....];
    const char *e = [d bytes];

    .... futz with e ....

    // [d self]; // uncomment this line to fix.
}

The above is not safe under GC because the compiler can decide that the stack slot holding 'd' be reused since there are no further references to 'd' in the scope. Add [d self]; at the end of the scope to ensure that the lifespan is preserved.

(There is a rather long winded discussion about this in the archives. It is mostly wrong, but may still be of interest.)

b.bum



_______________________________________________

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


  • Prev by Date: Re: High Scores local to iPhone app
  • Next by Date: "Arrange in Front" menu item and iterating over menus
  • Previous by thread: Re: High Scores local to iPhone app
  • Next by thread: "Arrange in Front" menu item and iterating over menus
  • Index(es):
    • Date
    • Thread