Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Oct 2004 20:03:31 +0200
From:      Willem Jan Withagen <wjw@withagen.nl>
To:        obrien@freebsd.org
Cc:        freebsd-amd64@freebsd.org
Subject:   Re: two 4GB mallocs => SEGV
Message-ID:  <417E9173.90406@withagen.nl>
In-Reply-To: <20041026173005.GA2984@dragon.nuxi.com>
References:  <20041026115041.GE2841@sivokote.iziade.m$> <20041026173005.GA2984@dragon.nuxi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?417E9173.90406>