From owner-freebsd-ports Fri Oct 26 12: 0:10 2001 Delivered-To: freebsd-ports@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2B93F37B403 for ; Fri, 26 Oct 2001 12:00:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f9QJ01s48411; Fri, 26 Oct 2001 12:00:01 -0700 (PDT) (envelope-from gnats) Received: from caida.org (ipn.caida.org [192.172.226.30]) by hub.freebsd.org (Postfix) with ESMTP id 14E9B37B401 for ; Fri, 26 Oct 2001 11:56:25 -0700 (PDT) Received: from localhost (jabrown@localhost) by caida.org (8.9.3+Sun/8.9.1) with ESMTP id LAA23943 for ; Fri, 26 Oct 2001 11:56:16 -0700 (PDT) Message-Id: Date: Fri, 26 Oct 2001 11:56:16 -0700 (PDT) From: Jeff Brown To: Subject: ports/31511: g++30 output SIGBUS-ing Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 31511 >Category: ports >Synopsis: g++30 produces binaries which SIGBUS when trying to use cout/cin/cerr/clog >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 26 12:00:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jeff Brown >Release: FreeBSD 4.1.1-RELEASE i386 >Organization: Mildly organized. >Environment: FreeBSD 4.1.1-R laptop system, using a ports tree from Oct 25, with the package "41upgrade-2000.11.01" installed, as well as a "make" binary from a 4.3-R system. >Description: Using gcc-3.0.1 built and installed with the "gcc30" port and its default options, simple C++ "hello world" programs compile but fail to execute properly. Any attempted I/O operations on cin/cout/cerr/clog result in a SIGBUS error, as the library attempts to dereference a NULL-valued pointer after subtracting 12 from it. The problem appears to be related to standard input/output/error; I/O operations on streams backed by files seem to work just fine. >How-To-Repeat: test.cc: ----------------- #include int main() { std::cout.flush(); return 0; } ----------------- % g++30 -g test.cc -o test % ./test Bus error (core dumped) A quick look in gdb reveals where things go South: the load from memory at 0x8054acc (which, in this instance, is loading from address 0x806a440) yields a value of "0". When it is offset and dereferenced as a pointer, havoc ensues. It would appear that something is screwing up the second argument to this function, "__os". (gdb) run Starting program: /usr/home/jabrown/broken-gcc/test Program received signal SIGBUS, Bus error. 0x8054ad1 in sentry (this=0xbfbff588, __os=@0x806a440) at ostream.tcc:39 39 : _M_ok(__os.good()), _M_os(__os) (gdb) disassemble 0x8054abc 0x8054ad3 Dump of assembler code from 0x8054abc to 0x8054ad3: 0x8054abc : push %ebp 0x8054abd : mov %esp,%ebp 0x8054abf : push %ebx 0x8054ac0 : sub $0x4,%esp 0x8054ac3 : mov 0x8(%ebp),%ebx 0x8054ac6 : sub $0xc,%esp 0x8054ac9 : mov 0xc(%ebp),%eax 0x8054acc : mov (%eax),%eax 0x8054ace : sub $0xc,%eax 0x8054ad1 : mov (%eax),%eax End of assembler dump. (gdb) print/x $eax $1 = 0xfffffff4 Since I'm pretty much a C++ newbie, and have little/no knowledge of the inner workings of the I/O libraries, I don't know what to do from here. >Fix: Use ifstreams for input, ofstreams for output. (Ouch.) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message