swarm-support
[Top][All Lists]
Advanced

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

Re: Segmentation Fault Blues...


From: Benedikt Stefansson
Subject: Re: Segmentation Fault Blues...
Date: Thu, 21 Aug 1997 15:03:57 -0700

address@hidden wrote:

>  For the life of me, I've really hit a "WALL".  If anyone
> wants to give me a quick tutorial on gdb, or how I could use gdb to
> diagnose this problem I would also appreciate it.

As Ted already pointed out to you "segmentation fault" means

>your program is messing around with memory (or objects) that it doesn't own 
>(or did but >doesn't anymore).  It's
playing with memory outside of its "segment".

These errors creep up all the time when you are programming in C, so you really 
have to spend some time and learn
how to avoid them and catch them when they happen.

In your case in Problem.m -step method you are missing the lines

    newX=x;
    newY=y;

before the line

    if (((float)[uniformDblRand  getDoubleWithMin: 0.0 withMax: 1.0]) 
<randomMoveProbability) {
   ...
If you look at the loop for a second you'll see that with probability 
randomMoveProbability newX and newY are not
set to anything before the next loop executes. Your agents are almost always 
trying to access other agents in the
world at bogus locations.

Fix this and the Swarm should run fine.

You would have found this problem with gdb. So the best investment of your time 
right now is to learn about memory
allocation in C and how to use GDB!

For hints on running gdb look at the relevant pages in the Swarm release such as

http://www.cons.org/cracauer/objc-hint-gdb.html

or the thread in the list archives under

http://www.santafe.edu/projects/swarm/archive/list-archive.9705/0033.html

Where you can also find a reference to an ftp site to download an Objective-C 
aware version of GDB (binaries
available for Linux on Intel).

There are also tons of stuff on the web about GDB.

Regards,
-Benedikt

----------------
Benedikt Stefansson                 address@hidden
Department of Economics, UCLA       Fax. (310) 825-9528
Los Angeles, CA 90095-1477          Tel. (310) 825-1777



                  ==================================
   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]