From owner-freebsd-amd64@FreeBSD.ORG Fri Aug 15 01:50:04 2008 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B8BC106564A for ; Fri, 15 Aug 2008 01:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D1A4F8FC14 for ; Fri, 15 Aug 2008 01:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m7F1o3Ca049466 for ; Fri, 15 Aug 2008 01:50:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m7F1o3O2049465; Fri, 15 Aug 2008 01:50:03 GMT (envelope-from gnats) Resent-Date: Fri, 15 Aug 2008 01:50:03 GMT Resent-Message-Id: <200808150150.m7F1o3O2049465@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-amd64@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Douglas William Thrift Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8878E1065671 for ; Fri, 15 Aug 2008 01:40:18 +0000 (UTC) (envelope-from douglas@slowhand.douglasthrift.net) Received: from slowhand.douglasthrift.net (slowhand.douglasthrift.net [69.55.236.40]) by mx1.freebsd.org (Postfix) with ESMTP id 425BD8FC08 for ; Fri, 15 Aug 2008 01:40:17 +0000 (UTC) (envelope-from douglas@slowhand.douglasthrift.net) Received: from slowhand.douglasthrift.net (slowhand.douglasthrift.net [69.55.236.40]) by slowhand.douglasthrift.net (8.14.3/8.14.3) with ESMTP id m7F1eH3a008467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 14 Aug 2008 18:40:17 -0700 (PDT) (envelope-from douglas@slowhand.douglasthrift.net) Received: (from douglas@localhost) by slowhand.douglasthrift.net (8.14.3/8.14.3/Submit) id m7F1eH8p008466; Thu, 14 Aug 2008 18:40:17 -0700 (PDT) (envelope-from douglas) Message-Id: <200808150140.m7F1eH8p008466@slowhand.douglasthrift.net> Date: Thu, 14 Aug 2008 18:40:17 -0700 (PDT) From: Douglas William Thrift To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 X-Mailman-Approved-At: Fri, 15 Aug 2008 02:40:02 +0000 Cc: Subject: amd64/126543: [amd64] __builtin_frame_address does not return 0 when reaching the top of the stack X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Douglas William Thrift List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Aug 2008 01:50:04 -0000 >Number: 126543 >Category: amd64 >Synopsis: [amd64] __builtin_frame_address does not return 0 when reaching the top of the stack >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-amd64 >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Aug 15 01:50:03 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Douglas William Thrift >Release: FreeBSD 7.0-STABLE-jc2 amd64 >Organization: >Environment: System: FreeBSD slowhand.douglasthrift.net 7.0-STABLE-jc2 FreeBSD 7.0-STABLE-jc2 #0: Thu Jun 26 21:33:03 PDT 2008 user@jail8.johncompanies.com:/usr/obj/usr/src/sys/jail8 amd64 >Description: On the amd64 architecture the gcc builtin function __builtin_frame_address does not return 0 when it is called for the level that should be the top of the stack. Instead it seems to continue returning addresses and then causes a bus error. GCC documentation: http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Return-Address.html I've seen this occur on this system and also on two systems running FreeBSD 7.0-RELEASE-p3. This causes devel/libexecinfo to be completely useless and crashy. >How-To-Repeat: Compile the following C program: #include int main(int argc, char *argv[]) { void *address; int index; for (index = 0; address != NULL && index != 5; ++index) { switch (index) { case 0: address = __builtin_frame_address(0); break; case 1: address = __builtin_frame_address(1); break; case 2: address = __builtin_frame_address(2); break; case 3: address = __builtin_frame_address(3); break; case 4: address = __builtin_frame_address(4); break; } printf("0x%x\n", address); } return 0; } Run on an i386 machine its output is fine: [douglas@backhome:~]$ ./test 0xbfbfec68 0xbfbfec9c 0x0 Run on an amd64 machine is not so fine: [douglas@justonenight:~]$ ./test 0xffffeaf0 0xffffeb40 0xffffecef 0x4c454853 Bus error: 10 (core dumped) The last hex value printed seems to consistently be a string from the environment variables. Judging by the two stack frame addresses printed on i386, perhaps the third address printed on amd64 is the one that should be a zero. >Fix: >Release-Note: >Audit-Trail: >Unformatted: