Re: Crash when using [NSTimer fire]
Re: Crash when using [NSTimer fire]
- Subject: Re: Crash when using [NSTimer fire]
- From: Shawn Erickson <email@hidden>
- Date: Fri, 19 Nov 2004 09:39:40 -0800
On Nov 19, 2004, at 9:19 AM, Gwynne wrote:
I'm experiencing a confusing crash when using NSTimer's -fire method
to force a timer to fire before its fire date. This happens when using
a timer with a very large interval (close order of 5 years), which I
do in order to avoid having to separate two extremely similar code
paths from each other. I started out with a non-repeating timer, but
it would somehow get invalidated immediately and therefore -fire
didn't work. I switched to a repeating timer (which didn't matter,
since the timer's selector invalidates and removes the timer anyway),
and ended up with a crash inside objc_msgSend() called from [NSCFTimer
fire]. I traced it down at the assembly level, and it seems that the
instance of NSTimer is getting mangled so when it calls -timeInterval
on itself, there's an invalid object there. I could only get the crash
to occur without assembly-level debugging, but there's nothing in my
secondary threads that goes anywhere NEAR that timer. I ran with
libguardmalloc, and nothing's tromping any memory. When I switched to
calling the timer's target/selector directly, the crash vanished and
exhaustive testing with both single-processor and multi-processor has
revealed no issues whatsoever. Is there any known issue with large
timer intervals and [NSTimer fire]?
To totally ignoring your core question. :-)
Why are using using a timer that way? I don't follow how a timer of 5
years is useful...
Guessing at what you are attempting to do... consider using an
NSConditionLock or some such thing if you are trying to gate something
from running, etc.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden