two 4GB mallocs => SEGV

Willem Jan Withagen wjw at withagen.nl
Tue Oct 26 11:03:33 PDT 2004


David O'Brien wrote:

> On Tue, Oct 26, 2004 at 02:50:41PM +0300, Georgi Guninski wrote:
> 
>>amdkotef64# cat test.c
>>#include <stdlib.h>
>>
>>int main(int ac, char **av)
>>{
>>char *a, *b;
>>size_t siz;
>>siz=4L*1024L*1024L*1024L;
>>printf("%lx\n",siz);
>>a=malloc(siz);
>>printf("%lx\n",a);
>>b=malloc(siz);
>>printf("%lx\n",b);
>>}
>>amdkotef64# gcc test.c
>>amdkotef64# ./a.out 
>>100000000
>>503000
>>/: write failed, filesystem is full
>>Segmentation fault
> 
> 
> I don't know why you didn't take this to the next step to try to figure
> out what was going on....
> 
>     # cc -g test.c
>     # gdb a.out
>     (gdb) run
>     Starting program: /var/tmp/a.out 
>     100000000
>     503000
> 
>     Program received signal SIGSEGV, Segmentation fault.
>     0x0000000200503002 in ?? () from /libexec/ld-elf.so.1
>     (gdb) where
> 
> now the output you get isn't but so helpful because you wind up in the
> middle of libc.  So if you build libc with -g and don't strip the lib
> when installing it you get:

A man is never too old to learn....
Thanx for the education, perhaps too simple to think of.

--WjW



More information about the freebsd-amd64 mailing list