Re: NSNull/NSarray .. count
Re: NSNull/NSarray .. count
- Subject: Re: NSNull/NSarray .. count
- From: arri <email@hidden>
- Date: Fri, 23 Mar 2007 07:52:48 +0100
thanks for your prompt replies!
meanwhile i found the cause...and i'm a bit ashamed of it...
but ok, there we go:
the call "i thought" was causing the problem:
int cnt = [[self planning] count];
was actually returning the correct count and has nothing to do with
the issue!
thanks 1/2Activist for pointing me to debugging that!
the problem was in a block of code further down, where 'cnt' is
evaluated,
and based on that, a bunch of other calls are potentially made..
i think i overlooked this because the app would hang at the weirdest
points,
because some important parts a run from the display-link thread (core-
video)
but ALWAYS when the above line was un-commented. (int cnt = ..)
anyway, somewhere linked to this block of code
i was trying to retrieve the index of an object in another array,
which only contained NULL object because of the REAL source of my
problem !
(a stupid mistake)
thanks to all for your thoughts: problem solved!
gr
arri
On Mar 23, 2007, at 06:50 18, Half Activist wrote:
THis really looks strange.
I'm thinking of two things that might happen:
- your 'planning' return value suddenly becomes NSNull, and there's
certainly a place in your code where you specify something as
NSNull and is then returned by the 'planning' method,
furthermore if you're in a multithreaded context then between two
calls, there is a probability that another thread is called, and
since you call NSLog, that writes tou a file descriptor, etc...,
it must be calling a system call that suspends this thread and
wakes up another in which you value changes.
I think about it because, a auto freed instance (say via
NSAutoreleasePool) wouldn't become NSNull, nor nil if not set, and
it would result in a crash, caused by a segmentation fault or
something of the kind.
There you get a valid instance of NSNull...
- If you're 100% sure of what you're doing, then there's always the
possibility of a compiler bug or maybe a framework bug.
Some years ago, when the firsts GCC 3.x came out, I remember
working on some project at the university, on a single threaded
application and one kind of call would work, say printf( "%d",
*aLongPtr ) but long aLong = *aLongPtr etc...
wouldn't work or vice versa. I remember I was doing stuffs on trees
that was using many pointers.
And I remember too that compiling with the latest (at the time)
from the 2.x series worked. (unless this was the other way round,
working on 3 not on 2.9, a bit fuzzy). Nevertheless, the problem
existed.
So what you could try is something like that:
int planningCount;
NSLog( @"%d", (planningCount = [ [ self planning ] count ]) );
I hope it helps though.
Regards.
On Mar 23, 2007, at 06:37 23, Andy Lee wrote:
Assuming [self planning] is non-trivial, what if you step through
it in the debugger to make sure sure it returns the same thing both
times?
--Andy
On Mar 23, 2007, at 06:31 52, Buddy Kurz wrote:
My guess would be that whatever [self planning] is was not retained
and the memory got reused by an instance of NSNull
----------------------------
On Mar 22, 2007, at 10:23 PM, arri wrote:
i'm baffled;
calling this:
NSLog(@"planning-count %d", [[self planning] count]);
..returns the expected count/number in the run-log,
but when doing this on the next line:
int cnt = [[self planning] count];
..the app hangs/quits, spitting this message:
2007-03-23 06:01:30.874 Placid[1265] *** -[NSNull count]: selector
not recognized [self = 0xa0806040]
2007-03-23 06:01:30.874 Placid[1265] An uncaught exception was raised
2007-03-23 06:01:30.874 Placid[1265] *** -[NSNull count]: selector
not recognized [self = 0xa0806040]
2007-03-23 06:01:30.874 Placid[1265] *** Uncaught exception:
<NSInvalidArgumentException> *** -[NSNull count]: selector not
recognized [self = 0xa0806040]
i would really like to get some pointers to what's going on here.
note that this is called from the display-link thread.
thanks
arri
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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