Subject: RE: The _weirdest_ segfault...
To: 'Andreas Falck' <faland-7@sm.luth.se>
From: Jeff Roberson <jroberson@aventail.com>
List: port-alpha
Date: 05/17/2000 12:41:45
Crashes in malloc are almost always due to overflowing some allocated area
or free()ing the same memory twice.  You have some how managed to corrupt
your heap.  

Does anyone know if NetBSD's libc has a malloc that watches for multiples
frees etc?  This is the only feature of glibc that I have ever liked..

Thanks,
Jeff

> -----Original Message-----
> From: Andreas Falck [mailto:faland-7@sm.luth.se]
> Sent: Wednesday, May 17, 2000 12:39 PM
> To: port-alpha@netbsd.org
> Subject: The _weirdest_ segfault...
> 
> 
> Hi!
> 
> I've been using NetBSD 1.4.1 on a 21164 for some while now. 
> It's a pc164
> oem motherboard, nothing special about that. However, 
> yesterday I ran into
> a weird thing that I cannot explain. I've had taken a course in unix
> system programming at my university, where the task was to 
> develop a shell
> on FreeBSD (x86). When it was done I decided to port i to the 
> alpha, and
> with a very few changes to the source code I made it compile without
> warnings (-Wall -Wpointer-arith -Wcast-align).
> Though, when trying to run it it failed very soon:
> 
> (gdb) run
> Starting program: /usr/home/andreas/src/amish/netbsd/amish 
> amish>pushd /usr
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x160541330 in malloc ()
> (gdb) backtrace
> #0  0x160541330 in malloc ()
> #1  0x1200062b0 in nexttoken () at tokenizer.c:126
> #2  0x120005888 in cmdparse (cmd=0x12010d060) at parser.c:278
> ...
> 
> **** Segfault in malloc!?! ****
> 
> Anyone knows or have an idea how it is possible? I could 
> guess it might
> have something to do with wrong alignment, but shouldn't the 
> kernel fix 
> such things? (my sysctl settings are such, according to the faq).
> 
> It's not that I need the shell running on my alpha (there are better
> shells :) but it would be interesting to know why it 
> segfaults. The only
> libraries included is readline and ncurses.
> 
> /Andreas
>