swarm-support
[Top][All Lists]
Advanced

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

gdb, stderr, totally baffing experience!


From: Paul Johnson
Subject: gdb, stderr, totally baffing experience!
Date: Fri, 24 Jan 2003 09:05:06 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020918

Hello everybody:

One of the Swarm users sent me a program that has a seg fault. I ran it through gdb and found that the line causing the trouble was a call to a +createBegin method. I mean, literally, the top line in the backtrace was in the ModelSwarm

newAgent = [Agent createBegin: self];

That was the one the debugger pointed to in step 1. That is somewhat unusual in my experience because usually gdb points at something you can see would cause a segfault. If the cause is inside +createBegin, for example, it would list a line in there.

So I rewrote the class to eliminate the need for it to override SwarmObject's +createBegin, so I could comment out +createBegin. Then the backtrace started pointing at a call to Swarm's built in uniformIntRand.

So I was starting to think that something is so dramatically wrong that gdb has no idea what to do, and I started putting in debug prints like this:

fprintf(stderr,"update family num_family is %d\n",num_family);

And then, to my total surprise and astonishment, I started getting bactraces where the fprintf was the causing the seg fault. Here's the bit from the backtrace

Program received signal SIGSEGV, Segmentation fault.
0x420503da in vfprintf () from /lib/i686/libc.so.6
(gdb) bt
#0  0x420503da in vfprintf () from /lib/i686/libc.so.6
#1  0x4205a297 in fprintf () from /lib/i686/libc.so.6
#2 0x08050ff4 in _i_Agent__updateFamily (self=0x8b6d2d8, _cmd=0x8058790) at Agent.m:438 #3 0x08050907 in _i_Agent__step (self=0x8b6d2d8, _cmd=0x8056e00) at Agent.m:256
#4  0x40017ddb in L10 () from /usr/lib/swarm/libswarm.so.0
#5  0x40205120 in objc_call (fa=0x8c36f10)

If I change all those fprintf statements to printf, then I still get the seg fault pointing at the fprintf, but it is back pointing at uniformIntRand or such.

So there's obviously something about gdb or stderr I don't understand. Do you?

One bit of information about this program. It is rather like the ArtificialStockMarket when I started revising that code--liberal use of C (structs, C arrays) interspersed with Obj-C. There could be significant array problems, like accesses of value[-1] or value[N+1] in an array that has valid index values from 0 to N.

Is it possible that, when some part of a program accesses memory so badly that it could damage memory in use by uniformIntRand in a way that totally baffles the gdb?


--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.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]