swarm-support
[Top][All Lists]
Advanced

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

Found my bug (was Re: Ever use electric fence with Swarm?


From: pauljohn
Subject: Found my bug (was Re: Ever use electric fence with Swarm?
Date: Thu, 14 Jun 2001 01:36:40 -0500

I did have an array overrun problem, let me describe it in case it ever
happens to you. A simulation would rarely crash, and only for certain
parameter values, and at different times on different machines, mostly
Windows.

I got ElectricFence and ran with it under gdb, and it turned up nothing,
which told me that I was not overrunning dynamically allocated memory.
Yipee.  EF is pretty easy to use, but it requires a ton of memory and
makes programs really really slow.

That left regular old static memory as the culprit, and when I realized
that, I found the problem.

I was iterating over a static array x with 8 elements (index 0 through
7).  Almost all the time, a variable "count" was between 0 and 7, so it
was safe to do x[i] for a randomly chosen i between 0 and count.  Now, a
logical mistake by me caused count, once in a blue moon, to be equal to
8.  However, this did not always crash the program, because the program
did not try to access the array at position 8 except when the draw from
a uniform distribution on [0,count] was equal to count (was equal to
8).  So, this infrequent, unpredictable outcome of assigning 8 only
caused a crash one time in 8.  That's why it was hard to track down.

Last week I stated in here that gdb under Windows did not give good
information about this crash, and I'd like to add that, as soon as I
found a set of parameter values that would cause the same crash in
Linux, the gdb output under Linux was exactly the same. I.e., it pointed
at a call to a method in which the mistake occurred, but did not point
at the line in which the mistake occurred.  All this is to say that gdb
5.0 under Windows  and Linux gave the same diagnostic information, which
is reassuring to the Windows audience, I suppose.

I would second Marcus's point that Java programs do not allow this kind
of bufoonery and the Java warnings about overruns of this sort is a
strong argument in its favor.  I'm working now in Objective C for other
reasons, mainly history of the project, the ease of debugging ( :) ) and
memory limitations.

"Marcus G. Daniels" wrote:
> 
> >>>>> "D4" == D D Donalson <address@hidden> writes:
>>
> D4> Check it on a W2000, and another Win 98 machine.  I  was never able to
> D4> get rid of the problem all together.
> 
> That sounds like an array overrun problem to me.

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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