• 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 a corrupted stack
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to debug a corrupted stack


  • Subject: Re: How to debug a corrupted stack
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 6 Aug 2008 19:59:31 +0700


On 6 Aug 2008, at 11:14, Ken Thomases wrote:

On Aug 5, 2008, at 9:51 PM, Gerriet M. Denkmann wrote:

I have a document based app which works perfectly with -O0 or -O1 but crashes with -O2 or higher.

When the crash occurs the debugger comes up and says: "Previous frame identical to this frame (corrupt stack?)"

When I try to step through the function (which is kind of difficult, as the optimization has shuffled the lines a lot) at some time the top frame of the stack gets duplicated.


Any help would be most welcome. I am completely run out of ideas and spent already hours with this bug.

You don't say what kind of crash it is? EXC_BAD_ACCESS?

I didn't say because no one told me. Especially not gdb. But I ran the program outside of Xcode and got a crash report with:


Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

The crash has nothing to do with aliases (they just created diffent paths through the code).
The program crashes when both -O2 (or better) and Generate Position- Dependend Code are set.


here r20 = 0x90ec (good)
0x00002b04 <+0464> lwz r4,0(r21)
0x00002b08 <+0468> mr r5,r29
0x00002b0c <+0472> mr r3,r24
0x00002b10 <+0476> bla 0xfffeff00 <objc_msgSend_rtp> = [ a addChild: b ]
now r20 = 0 (bad)
...
0x00002b4c <+0536> lwz r4,0(r20) <---- crash here, because r20 = 0
0x00002b50 <+0540> mr r3,r29
0x00002b54 <+0544> bla 0xfffeff00 <objc_msgSend_rtp> = [ b release ]


If someone wants to check whether it really is a compiler bug (and not just some stupidity on my side) I can send the whole project.
10.4.11 - not tested on 10.5


This was difficult to debug, because -O2 keeps most variables in registers, so whenever I did
"po a" I got the answer: "No symbol "a" in current context."
And the two identical stack-frames are maybe a gdb bug (the crash report had a normal stack trace).



Anyway - I switched off the Generate Position-Dependend Code (Faster function calls for applications) and all is fine again (after a day lost fighting with the compiler).



Kind regards,

Gerriet.

_______________________________________________

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


References: 
 >How to debug a corrupted stack (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: How to debug a corrupted stack (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: autorelease CGImageRef?
  • Next by Date: Dumb Q
  • Previous by thread: Re: How to debug a corrupted stack
  • Next by thread: Re: How to debug a corrupted stack
  • Index(es):
    • Date
    • Thread