swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange messages


From: Roger Burkhart
Subject: Re: strange messages
Date: Tue, 11 Jun 96 10:57:59 MDT

> Recently, I ran into a problem which I could not resolve to my own
> mistake though I cannot tell for sure. What happens is that the program
> crashes because an arbitrary message send happens that I never define.
> After some debugging I found out that actually data is taken from 
> memory locations near my variables and this is interpreted as an
> object and sent messages to.

Hmm, sure sounds like something is executing that shouldn't be, the
question is what it is and how it got there.

> In the following example, the adress in 
> "test1" will be sent a message with method "step". Interestingly, the
> correct object, co2Curve is ALSO sent the message, so all in all, one
> superfluous message is sent to a foul destination. Therefore, this 
> problem remains unnoticed, as long as test1 contains 0x0.

Put a break in nil_method, or use a patched version of the objective C
runtime library (libobjc.a) that aborts when you send a message to a nil
message (see the Swarm page on Objective C debugging hints for more info).
That way you can intercept the invalid message send as early as possible,
instead of waiting for a non-nil value.  It may also be specific to this
particular error, allowing you to zero in to just that message send.  In
Swarm's use of Objective C, messages to nil object id's are *never*
considered legitimate, so trapping them is always worth doing and
sometimes finds errors that otherwise remain hidden.

> I was too lazy to find out WHO is actually sending the message (it could
> be eihter the scheduler, or a followup like the co2Curve).
> I did however check that the message send is caused
> by the entry in the ActionGroup as shown in the code below.
> Is there an easy way to see where a message is comming from that
> gets rejected?

In the gdb debugger, do a stack trace ("bt" or "where") after the message
lookup fails, and you should see the calling levels on the stack including
all passed arguments.  That often is enough to give a good indication.

> Am I doing something wrong with schedules or ActionGroups or whatever?
> 
> Here is the code:

No, I don't see anything wrong.  Keep in mind that when you create an
action to an object id you pass to createActionTo:, it takes the value
of that id at the time the action is created.  If the id comes from an
instance variable, like your co2Curve, it won't read new values of that
variable but only keep using the original value.  But your code looks
like it initializes the variable just once and uses that, so this doesn't
seem to be a problem.

What I'd recommend for now is to see what is generating the invalid
message send, and from where.  If you can get a stack trace at the time
of error that should help.  Send a copy of the stack trace if you'd
like explanation of the call levels that may be present.

Roger Burkhart




reply via email to

[Prev in Thread] Current Thread [Next in Thread]