• 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: NSTimer - crash when closing window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer - crash when closing window


  • Subject: Re: NSTimer - crash when closing window
  • From: Jens Bauer <email@hidden>
  • Date: Sat, 11 Oct 2003 11:33:30 +0200

Hi Alastair,

On Saturday, Oct 11, 2003, at 09:47 Europe/Copenhagen, Alastair J.Houghton wrote:

On Saturday, October 11, 2003, at 08:12 am, Jens Bauer wrote:

-Can you tell me why it crashes, and how to avoid it ?

Have you tried using the debugger? It'll show you which function it crashes in, which will give you (and us, if you're still stumped) a *big* clue. Get a stack backtrace (enter "bt" in the debugger's console window) and take a look to see which functions have been called.

Woops, having seen the crashlog so many times, it's always in the same line, I forgot including the crash-log.

It's the very first line of timerTask, indicating that either 'self' or data in 'self' is invalid.

---8<-----8<-----8<-----
#0 0x9068ba54 in objc_msgSend ()
#1 0x0000429c in -[AnimationDocument timerTask:] (self=0x5a3fc0, _cmd=0xfc2c, aTimer=0x1739980) at Classes/AnimationDocument.m:181/Users/jens/Sources/AnimationApp/
#2 0x97df4dd8 in __NSFireTimer ()
#3 0x90163230 in CFRunLoopRemoveTimer ()
#4 0x90148d28 in CFRunLoopRunInMode ()
#5 0x90180f58 in CFRunLoopRunSpecific ()
#6 0x969a3b70 in GetEventClass ()
#7 0x969b3a78 in GetKeyboardFocus ()
#8 0x969dabbc in BlockUntilNextEventMatchingListInMode ()
#9 0x9308dedc in _DPSNextEvent ()
#10 0x930a0158 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#11 0x930b1d88 in -[NSApplication run] ()
#12 0x9315fc58 in NSApplicationMain ()
#13 0x00003854 in main (argc=1, argv=0xbffffc4c) at main.m:13/Users/jens/Sources/AnimationApp/
--->8----->8----->8-----

I tried simplifying the code:

- (void)timerTask:(NSTimer *)aTimer
{
id my_i;
int my_state;

my_i = playBackwardButton;
my_state = [my_i state]; // this line crashes
}

-Note: playBackwardButton can be read, which means self is OK, but the button is no longer a valid object.

I assume that the timerTask method has been invoked *after* the window was closed.
If I put the lines...

fprintf(stderr, "windowWillClose\n"); fflush(stderr);
fprintf(stderr, "dealloc\n"); fflush(stderr);

in both -dealloc and -windowWillClose, nothing is printed before the crash!
-Which means, it seems that neither windowWillClose, nor dealloc gets called before the crash.
-I've tried setting breakpoints in the 2 methods, but the debugger doesn't stop there either.

Should I do my cleanup in some method other than -dealloc and -windowWillClose then ??


Love,
Jens
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSTimer - crash when closing window
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: NSTimer - crash when closing window (From: "Alastair J.Houghton" <email@hidden>)

  • Prev by Date: Re: NSTimer - crash when closing window
  • Next by Date: Re: Sending data to libxslt
  • Previous by thread: Re: NSTimer - crash when closing window
  • Next by thread: Re: NSTimer - crash when closing window
  • Index(es):
    • Date
    • Thread