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

Re: Segfaults & ld.so wierditude



Bob Ham <u9rah [at] dcs.shef.ac.uk> tapped some keys and produced:

> Well, I had another play.  The problem was that I had a function that 
> was trying to return the address of an array element, only it was using 
> a negative subscript at times.  Goodness what what gdb was doing, 
> reporting backtraces in only __libc_start_main(), considering the
> function was about three calls deep :/

Make sure you have the latest version of gdb. You're not using threads
are you? gdb tends to screw them up a bit (the latest version fixes it,
kinda)
 
> Anyway, that problem solved, and another one reared it ugly head again. 
> It's a different program, but the code is part of the same project.  The 
> problem is in malloc().  Strangely, malloc() segfaults (on the second 
> call of two seccusive ones in the backtrace; can't think why that is) 
> but it only does so after the the function has run through once already. 
> It's strdup() that is called from my code, but I changed it to a 
> malloc() call to see if it made a difference, and it didn't.

Hmmm, odd.
 
> http://www.dcs.shef.ac.uk/~u9rah/gcb-2000-04-27-0044.tar.bz2 (123 Kb)

wgetted. :)

> The offending code is in the gcb/ircfe/irc_msg.c file, in the function 
> buf2irc_msg, which calls a strdup_inc() function in 
> gcb/common/gcb_string.c which then calls strdup().  The point at which 
> it used to segfault (without the surrounding malloc() and free() calls)
> is in irc_msg.c, line ~215 (can't remember exactly.)

I'll have a play. (Not much else to do till Tuesday :)

-- 
H 3@H 3@

---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.