Subject: Re: The _weirdest_ segfault...
To: David Brownlee <abs@netbsd.org>
From: Andreas Falck <faland-7@sm.luth.se>
List: port-alpha
Date: 05/17/2000 23:05:31
On Wed, 17 May 2000, David Brownlee wrote:

> 	OK - my money is with everyone else's on "the something else is
> 	corrupting malloc()'s memory" bet :)
> 
> 	Random options include adding an extra 1K to every malloc length	
> 	call to see if that fixes it (if it does you have a good idea of
> 	the problem)

Yep, it works a lot better! I did a 

#define malloc(x) malloc(x+1000)

in a global header and now most things work. Now instead it seems to have
forgotten how to close its file descriptors (not due to the malloc fix, i
just didn't get far enough to find it out before now), but that was
someone elses part of the code so I do'nt feel like digging into it now.

However, what is the conclusion about the memory thing, alignment problems
or what?

Thanks for your help (everyone)!

And please, if you discuss this further on the list today, send a cc
directly to me. I joined today (have been off the list for a while) and
since I use another address my request went to the listmaster for
approval.

/Andreas

> 
> 		David/absolute
> 				       -- www.netbsd.org: No hype required --
> 
> On Wed, 17 May 2000, Andreas Falck wrote:
> 
> > 
> > Oh yeah, it could help too :)
> > 
> > 'i'  is the size of the token:
> > 
> > amish>pushd /usr
> > [5]
> > [4]
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x160541330 in malloc ()
> > 
> > i=5 chrashes too, even though it worked above. But this works:
> > 
> > amish>pushd /usrrr
> > [5]
> > [6]
> > amish>
> > 
> > i=8 works, but the next segfault comes from within the readline lib!
> > 
> > #0  0x160541330 in malloc ()
> > #1  0x160235c3c in xmalloc ()
> > #2  0x1602210a8 in maybe_save_line ()
> > ... (libreadline functions)
> > 
> > Still strange...
> > 
> > /Andreas
> > 
> > 
> > On Wed, 17 May 2000, David Brownlee wrote:
> > 
> > > 	What is i at that point (can you add a printf() directly before
> > > 	the malloc())
> > > 
> > > 	It could be general memory corruption, but its much easier to 
> > > 	verify the args passed first :)
> > > 
> > > 
> > > 		David/absolute
> > > 				       -- www.netbsd.org: No hype required --
> > > 
> > > On Wed, 17 May 2000, Andreas Falck wrote:
> > > 
> > > > > 	Out of curiosity, what value are you passing to malloc()?
> > > > > 
> > > > Of course, I forgot:
> > > > 
> > > > temp = malloc((i + 1) * (sizeof(char)));
> > > > 
> > > > It allocates memory for a token out of a whitespace-separated string.
> > > > 
> > > > /Andreas
> > > > 
> > > > 
> > > 
> > > 
> > 
> > 
> 
>