Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Oct 2001 11:56:16 -0700 (PDT)
From:      Jeff Brown <jabrown@ipn.caida.org>
To:        <FreeBSD-gnats-submit@freebsd.org>
Subject:   ports/31511: g++30 output SIGBUS-ing
Message-ID:  <Pine.GSO.4.33.0110261154340.16460-100000@ipn.caida.org>

next in thread | raw e-mail | index | archive | help

>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 <iostream>
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 <sentry>:     push   %ebp
0x8054abd <sentry+1>:   mov    %esp,%ebp
0x8054abf <sentry+3>:   push   %ebx
0x8054ac0 <sentry+4>:   sub    $0x4,%esp
0x8054ac3 <sentry+7>:   mov    0x8(%ebp),%ebx
0x8054ac6 <sentry+10>:  sub    $0xc,%esp
0x8054ac9 <sentry+13>:  mov    0xc(%ebp),%eax
0x8054acc <sentry+16>:  mov    (%eax),%eax
0x8054ace <sentry+18>:  sub    $0xc,%eax
0x8054ad1 <sentry+21>:  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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.33.0110261154340.16460-100000>