From owner-freebsd-amd64@FreeBSD.ORG Tue Oct 26 17:30:10 2004 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BD3216A4CE; Tue, 26 Oct 2004 17:30:10 +0000 (GMT) Received: from dragon.nuxi.com (trang.nuxi.com [66.93.134.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id B4B9D43D5A; Tue, 26 Oct 2004 17:30:09 +0000 (GMT) (envelope-from obrien@NUXI.com) Received: from dragon.nuxi.com (obrien@localhost [127.0.0.1]) by dragon.nuxi.com (8.13.1/8.13.1) with ESMTP id i9QHU8X8003228; Tue, 26 Oct 2004 10:30:08 -0700 (PDT) (envelope-from obrien@dragon.nuxi.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.13.1/8.13.1/Submit) id i9QHU6uu003227; Tue, 26 Oct 2004 10:30:06 -0700 (PDT) (envelope-from obrien) Date: Tue, 26 Oct 2004 10:30:05 -0700 From: "David O'Brien" To: Georgi Guninski Message-ID: <20041026173005.GA2984@dragon.nuxi.com> References: <20041026115041.GE2841@sivokote.iziade.m$> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041026115041.GE2841@sivokote.iziade.m$> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 6.0-CURRENT Organization: The NUXI BSD Group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 cc: roam@FreeBSD.org cc: freebsd-amd64@FreeBSD.org Subject: Re: two 4GB mallocs => SEGV X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: obrien@FreeBSD.org List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2004 17:30:10 -0000 On Tue, Oct 26, 2004 at 02:50:41PM +0300, Georgi Guninski wrote: > amdkotef64# cat test.c > #include > > 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: (gdb) run Starting program: /var/tmp/a.out 4294967296 5255168 Program received signal SIGILL, Illegal instruction. 0x0000000200503000 in ?? () from /libexec/ld-elf.so.1 (gdb) where #0 0x0000000200503000 in ?? () from /libexec/ld-elf.so.1 #1 0x000000020069579d in map_pages (pages=8595189760) at /usr/src/lib/libc/stdlib/malloc.c:338 #2 0x0000000200695c19 in malloc_pages (size=1048576) at /usr/src/lib/libc/stdlib/malloc.c:572 #3 0x0000000200695f77 in imalloc (size=4294967296) at /usr/src/lib/libc/stdlib/malloc.c:740 #4 0x00000002006968ed in pubrealloc (ptr=0x0, size=4294967296, func=0x2006f8c88 " in malloc():") at /usr/src/lib/libc/stdlib/malloc.c:1128 #5 0x00000002006969d8 in malloc (size=8595189760) at /usr/src/lib/libc/stdlib/malloc.c:1152 #6 0x00000000004007b4 in main (ac=1, av=0x7fffffffe900) at test.c:11 malloc.c:map_pages() calls brk(2) and this is where it goes to la-la land. -- -- David (obrien@FreeBSD.org)