swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] Avoidance of Crashes by using the "next - button"


From: Konrad_Richter
Subject: Re: [Swarm-Support] Avoidance of Crashes by using the "next - button"
Date: Thu, 29 Sep 2005 22:51:00 +0200


Dear John,
many thanks on your exhaustive reply!
Many greetings,
        Konrad
       
______________________________________        
       
Konrad Richter
McKinsey & Company, Inc.
Herrengasse 1-3
A-1010 Wien
Austria
       
Phone +43 1 5370-6160
Fax +43 1 5370-6161
Mobile +49 175 318-6160
       



Paul Johnson <address@hidden>
Sent by: address@hidden

28.09.2005 19:23

Please respond to
Swarm Support <address@hidden>

To
Swarm Support <address@hidden>
cc
Subject
Re: [Swarm-Support] Avoidance of Crashes by using the "next - button"





I downloaded the code and ran the model in gdb.  That's the only way to
see why it crashes.  On  my system, it crashes much sooner, timestep 1.

If using "next" changes that, it is because you have an error in
dynamically allocated memory, and using next somehow slightly changes
the way the system gets memory.

The error is triggered by line 213, and it is happening because "aBank"
is is not there where you want it. Instead, some NormalDist object is
sitting in its place.

With lists, it is generally bad to use atOffset: because it does not
protect you very much.  If you are really  using "at offet" to insert
stuff into a Swarm List, I think there is a real danger because there is
no way to make sure all of the spaces get filled in. Use addLast and
debug that.

Also, If you rewrite your loops to use the method I recommend in the
user guide it will be safer. FOr example, when you do those for loops
like this:

  for (i=0; i<numBanks; i++){
    aBank=[bankList atOffset: i];
    [aBank updateDefaults];
    [aBank updateProfits];
    [aBank updateRWA];
    [aBank updateCapRat];
  }

It assumes you are correct in believing that there are "numBanks" banks
in the list and that none are nil.  I believe that there are not
numBanks in your collection, and that is why the crash happens. You ask
for the "50th" element in a collection that has only 43 or such.

Now, here I think is the most fatal problem.  Please note also that when
you do "drop" on an item it a list, it puts a nil into the list.

When your ModelSwarm.m: 142 has this
   if ([aBank getCapital]<capTreshold || [aBank
getCapRat]<capRatTreshold) {
      [[bankList atOffset: i]drop];
      newBank = [Bank createBegin: self];
      [newBank createEnd];
      [newBank setID: i];

It does not remove "aBank" from the list, but rather drops it from
memory. So the list has a "nil" there.  So when you used "addLast" it
puts an object on the end of the collection, but does not remove the
"nil".  The Collections protocol has a method for removing objects from
lists.  And then, when you use "addLast" later on, it means that your
"numBanks" no longer matches the number of items in your collection.

You might consider using a Swarm Array for collections that have a hard,
fixed number of members, then you  can put and atOffset all you want.
But if you are needing an expandable collection, one that uses addLast,
then it won't work.

pj



Here's the gdb trace:

#0  0xb7f51402 in __kernel_vsyscall ()
#1  0x4e8de118 in raise () from /lib/libc.so.6
#2  0x4e8df888 in abort () from /lib/libc.so.6
#3  0xb7e7de16 in debugabort (filename=0x0, lineno=0, function=0x0)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/misc/debugabort.c:9
#4  0xb7e53a36 in -[Error(c) _raiseEvent:] (self=0x952af90,
_cmd=0xb7f15c60,
    eventData=0xb7e8bd5f)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/defobj/Symbol.m:187
#5  0xb7e4771c in -[Object(s) _doesNotRecognize:] (self=0x969c768,
    _cmd=0xb7f15d40, sel=0x0)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/defobj/DefObject.m:833
#6  0xb7e4a64b in -[Object(s) _forward::] (self=0x969c768, _cmd=0x9504388,
    aSel=0x804e2b0, argFrame=0xbfb50c20)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/defobj/DefObject.m:737
#7  0xb7e86fad in __objc_forward (object=0x969c768, sel=0x804e2b0,
    args=0xbfb50c20)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/libobjc/sendmsg.c:596
#8  0xb7e87503 in __objc_double_forward (rcv=0x0, op=0x6)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/libobjc/sendmsg.c:545
#9  0x0804ab8a in -[ModelSwarm updateAverages] (self=0x961d178,
_cmd=0x804e330)
    at ModelSwarm.m:213
#10 0x0804a07c in -[ModelSwarm step] (self=0x961d178, _cmd=0x804edd0)
    at ModelSwarm.m:111
#11 0xb7e66feb in L10 () from /usr/lib/swarm/libswarm.so.0
#12 0x0961d178 in ?? ()
#13 0x0804edd0 in _OBJC_SELECTOR_TABLE ()
#14 0xbfb50cd8 in ?? ()
#15 0xb7e33ba2 in -[ActionGroup(c) __performPlan:] (self=0x96cd738,
    _cmd=0x96cbc10)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/CompoundAction.m:176
#16 0xb7e55eb3 in -[FCall(c) _performCall] (self=0x96ca1a0, _cmd=0xb7f03448)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/defobj/FCall.m:757
#17 0xb7e3c58d in -[Activity(c) __run:] (self=0x95bc370, _cmd=0xb7f0c4a8)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/XActivity.m:257
#18 0xb7e3c495 in -[Activity(c) __run:] (self=0x96cf168, _cmd=0xb7f0c4a8)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/XActivity.m:207
#19 0xb7e3c495 in -[Activity(c) __run:] (self=0x96c41d0, _cmd=0xb7f0c4a8)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/XActivity.m:207
#20 0xb7e3c495 in -[Activity(c) __run:] (self=0x96c6190, _cmd=0xb7f0c4a8)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/XActivity.m:207
#21 0xb7e3c3d3 in -[Activity(c) _run] (self=0x96c6190, _cmd=0xb7eb1480)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/activity/XActivity.m:93
#22 0xb7dd9097 in -[ControlPanel startInActivity:] (self=0x95bb488,
    _cmd=0xb7eb26d0, activityID=0x96c6190)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/simtoolsgui/ControlPanel.m:99
#23 0xb7dd9b89 in -[GUISwarm go] (self=0xb7eb26d0, _cmd=0x804d290)
    at
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.2/src/simtoolsgui/GUISwarm.m:70
#24 0x08048c0a in main (argc=0, argv=0x0) at main.m:29




address@hidden wrote:
>
> Hi,
> I just came across a strange thing:
> On my computer, the attached simulation crashes in timestep 22, if I run
> the simulation "normally". However, by repeatedly using the
> "next"-button on the control panel, the simulation proceeds without
> problems. Just was just curious, wether anyone has an explanation for this.
> Obviously it also would be nice if someone has an idea how I could avoid
> the crash - the responsible line seems to be line 213 in modelSwarm.m.
> Cygwin tells me that "NormalDist does not recognize getGin". However, in
> line 213 I call "aBank" which is not a normalDistribution. I am confused
> ...
>
> I am using Swarm 2.2. on Windows XP.
> Greetings,
>         Konrad
>        
>
> ______________________________________        
>        
> Konrad Richter
> McKinsey & Company, Inc.
> Herrengasse 1-3
> A-1010 Wien
> Austria
>        
> Phone +43 1 5370-6160
> Fax +43 1 5370-6161
> Mobile +49 175 318-6160
>        
>
> +=========================================================+
> This message may contain confidential and/or privileged
> information.  If you are not the addressee or authorized to
> receive this for the addressee, you must not use, copy,
> disclose or take any action based on this message or any
> information herein.  If you have received this message in
> error, please advise the sender immediately by reply e-mail
> and delete this message.  Thank you for your cooperation.
> +=========================================================+
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support


--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66044-3177           FAX: (785) 864-5700
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support



+=========================================================+
This message may contain confidential and/or privileged
information.  If you are not the addressee or authorized to
receive this for the addressee, you must not use, copy,
disclose or take any action based on this message or any
information herein.  If you have received this message in
error, please advise the sender immediately by reply e-mail
and delete this message.  Thank you for your cooperation.
+=========================================================+





reply via email to

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