swarm-modeling
[Top][All Lists]
Advanced

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

[Swarm-Modelling] Unexepected nil receivers in Objective-C swarm code


From: William Shu
Subject: [Swarm-Modelling] Unexepected nil receivers in Objective-C swarm code
Date: Fri, 15 Feb 2008 18:00:11 +0100

Hi,
I am trying to make a re-entry into the use of swarm, so excuses if
problem not well-posed.

I have tried to modify my piece of Objective-C swarm code (version
2.1) which worked reasonably well with swarm 2.1.1. under windows 98
so that it runs with swarm 2.4 under linux (Scientific Linux 5.0).
Update essentially means explicitly checking for nil receivers to
objective C messages.

My difficulties at this stage are two-fold (swarm and use of the the
gdb debugger) but I focus here on swarm/swarm code: (A) display of
structs and unions; (B) Executing swarm library methods from within
debugger; (C) nil receivers in my swarm code .

I hope someone can help, as I am at wits end, especially as I
currently have very slow internet lines! Below, I give further
details: Outline description of code, hypotheses on the problem I
face, and a Sample Debugger output.

William.


A) Display of structs and union.
Swarm objects to display of structs and unions. Is there no way to let
it ignore is error as a warning message. (I am not in a state to
modify the program code now!)


C) Executing swarm library methods from within debugger: The debugger
()GNU gdb Red Hat Linux (6.5-16.el5rh) does not seem able to run the
swarm library methods, and when I interrupt the program (using stop or
break  from within debugger), I cannot resume execution afterwards!



C) Problems with my swarm code.

OUTLINE DESCRIPTION OF WORKING CODE
Essentially, my swarm code creates a number of agents in separate
model swarms whose actiongroup does the following for each:
 (a) use the step method to model each agent's activity
 (b) use the dropAgents method, *NEXT* to drop (remove) any agents
marked for removal (via method dropDead called from the step method
above).  The "body" (memory allocated) of dropped agents are actually
stored in a list and re-used in the creation of new agents by the
createBody* methods below. (this saves a lot of execution time!)
(c) update a Grid2d space (valueSpace) for display.

The agents are created via one of three createBody* methods, which
eventually invoke their respective createBegin and createEnd methods.


HYPOTHESES ON PROBLEM
>From stepping through the code, I notice that  agents that have
dropped dead (marked as dead, and some of their resources/objects
returned) and should be removed from their swarm are still there and
causing the access to nil values. Insertion of debug code does not
reveal the problem. (When I try dropping agents immediately (using the
swarm drop method) rather than delay using dropDead, my code crashes
most unpredictably, somewhere in the swarm code!)

I can only conjecture that any one of the following is a possible
causes for the access to nil receivers:
(a) the step method above is called more than once before the
dropAgents method, and so accounts for use of "dead" agents.

(b) agents are created elsewhere in the code, and so their variables
are not initialised properly, leading to nil receivers.

(c) some code holds id to swarm (such as a Grid2d world), and somehow
feeds it in the swarm process.

(d) There is some multi-threading that does not respect the sequencing
in the buildActions action groups of swarm!


SAMPLE DEBUGGER OUTPUT:

  Current directory is /home/wss/tmpMosq/protoMkv/
GNU gdb Red Hat Linux (6.5-16.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/i686/nosegneg/libthread_db.so.1".

(gdb) run
Starting program: /home/wss/tmpMosq/protoMkv/simalaria
[Thread debugging using libthread_db enabled]
[New Thread -1208858944 (LWP 9578)]
[New Thread 26852240 (LWP 9579)]
*** event raised for warning: WarningMessage
*** function: -[VarProbe _setupObjcVarProbe:](), file:
/home/pauljohn32/LinuxDownloads/redhat/BUILD/swarm-2.2.4/src/objectbase/VarProbe.m,
line: 232
Probing of unions and structs not supported.
[class: `Person', variable: `location']
*** execution continuing...

Mosquito: getUnhappiness: unexpected nil colonyList: ignored
nil receiver for xpdDropDeadFromAge:
Mosquito: step: ***DEBUG INFORMATION***: agent *is* in dropList[ 4]
and seems to be in its swarm! Agent AGT 924a9b0 is still in its swarm!
Program received signal SIGABRT, Aborted.
[Switching to Thread -1208858944 (LWP 9578)]
0x00982402 in __kernel_vsyscall ()
(gdb) bt
#0  0x00982402 in __kernel_vsyscall ()
#1  0x4d650df0 in raise () from /lib/i686/nosegneg/libc.so.6
#2  0x4d6526d1 in abort () from /lib/i686/nosegneg/libc.so.6
#3  0x002748b8 in nil_method () from /usr/lib/swarm/libswarm.so.0
#4  0x080521ba in -[Mosquito step] (self=0x924a9b0, _cmd=0x808d8d0)
    at Person.m:1448
#5  0x00250dfb in __builtin_avcall () from /usr/lib/swarm/libswarm.so.0
#6  0x0024e672 in objc_call () from /usr/lib/swarm/libswarm.so.0
#7  0x0023d49e in updateTarget () from /usr/lib/swarm/libswarm.so.0
#8  0x0021e15d in get_number_of_arguments () from /usr/lib/swarm/libswarm.so.0
#9  0x00229ece in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#10 0x00229cd6 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#11 0x00229cd6 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#12 0x00229cd6 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#13 0x00229cd6 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#14 0x00229cd6 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#15 0x0022a322 in _activity_context_error () from /usr/lib/swarm/libswarm.so.0
#16 0x001b6471 in swarm_force_references () from /usr/lib/swarm/libswarm.so.0
#17 0x001b6e8a in swarm_force_references () from /usr/lib/swarm/libswarm.so.0
#18 0x08057358 in main (argc=Cannot access memory at address 0x256a
) at TopLevel.m:65
(gdb) up 4
#4  0x080521ba in -[Mosquito step] (self=0x924a9b0, _cmd=0x808d8d0)
    at Person.m:1448
(gdb) p *self
$1 = {{{{{{{{isa = 0x80816c0}, zbits = 153397834, foreignEntry = 0x0}}}}},
    birthday = 0, position = {x = 0, y = 0}, objectStatus = 0,
    displayStatus = 0, behaviourStatus = 0, clusterList = 0x0,
    scheduleCount = 0, world = 0x0, valueSpace = 0x0, modelSwarm = 0x0,
    panel = 0x0, smlColor = 0 '\000'}, infectionDate = 0, sex = female,
  bodyResistance = 0.84999999999999998, colonyList = 0x0, livingState = dead,
  ethology = 0x0, randomMoveProbability = 0}
(gdb)


B) use of the GNU gdb Red Hat Linux (6.5-16.el5rh) debugger.


reply via email to

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