public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: nikhild@flashmail.com
To: gcc-gnats@gcc.gnu.org
Cc: nikhild@flashmail.com
Subject: libstdc++/6991: Seg fault in std::num_put (called from ostringstream::operator<<) while putting numbers
Date: Tue, 11 Jun 2002 07:06:00 -0000	[thread overview]
Message-ID: <20020611135615.32299.qmail@sources.redhat.com> (raw)


>Number:         6991
>Category:       libstdc++
>Synopsis:       Seg fault in std::num_put (called from ostringstream::operator<<) while putting numbers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 11 07:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Nikhil Deshpande
>Release:        GCC 3.0.4
>Organization:
>Environment:
AIX 4.3.3.0
GNU binutils 2.12.1
GCC 3.0.4
>Description:
- Seg fault when writing (operator<<) numbers to 
  ostringstream.
- BUT seg fault only if os << i statement is followed by
  os.str() call. If os.str() is removed, it does not crash.
  e.g. 
    ostringstream os;
    int i = 1234;
    os << i; // crashes here
    os.str(); // presence of this stmt effects above crash
- Also happens for long, float, double etc. (any number).

----------------------------------------------------------

GNU gdb 5.2
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-ibm-aix4.3.3.0"...
Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
bt#0  0x10002888 in std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (
    this=0x60002, __s=
      {<iterator<std::output_iterator_tag,void,void,void,void>> = {<No data fields>}, _M_sbuf = 0x2ff2289c, _M_failed = false}, __f=@0x2ff228f0, __fill=32 ' ', __v=1234)
    at /usr/local/gcc-3.0.4/include/g++-v3/bits/locale_facets.h:758
758           { return do_put(__s, __f, __fill, __v); }
(gdb) bt
#0  0x10002888 in std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (
    this=0x60002, __s=
      {<iterator<std::output_iterator_tag,void,void,void,void>> = {<No data fields>}, _M_sbuf = 0x2ff2289c, _M_failed = false}, __f=@0x2ff228f0, __fill=32 ' ', __v=1234)
    at /usr/local/gcc-3.0.4/include/g++-v3/bits/locale_facets.h:758
#1  0x100014f4 in std::ostream::operator<<(long) (this=0x2ff22898, __n=1234)
    at /usr/local/gcc-3.0.4/include/g++-v3/bits/ostream.tcc:157
#2  0x10000848 in std::ostream::operator<<(int) (this=0x2ff22898, __n=1234)
    at /usr/local/gcc-3.0.4/include/g++-v3/bits/std_ostream.h:120
#3  0x100004e4 in main (argc=1, argv=0x2ff229e8) at t.cc:6
#4  0x100001dc in __start ()

----------------------------------------------------------

storab@kansai ~/nikhild/test>g++ -v
Reading specs from /usr/local/gcc-3.0.4/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.0.4/specs
Configured with: ../gcc-3.0.4/configure --prefix=/usr/local/gcc-3.0.4 --enable-threads=posix --enable-languages=c,c++ --disable-libgcj
Thread model: single
gcc version 3.0.4
----------------------------------------------------------

storab@kansai ~/nikhild/test>g++ -v -pthread
Reading specs from /usr/local/gcc-3.0.4/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.0.4/specs
Configured with: ../gcc-3.0.4/configure --prefix=/usr/local/gcc-3.0.4 --enable-threads=posix --enable-languages=c,c++ --disable-libgcj
Thread model: posix
gcc version 3.0.4
g++: No input files
>How-To-Repeat:
1. Compile t.cc example source code with g++ 3.0.4
   g++ -pthread -g t.cc
2. Run (which results in to seg fault).
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="t.cc"
Content-Disposition: inline; filename="t.cc"

#include <sstream>

int main(int argc, char* argv[]) {
    int i = 1234;
    std::ostringstream os;
    os << i;
    os.str();
    return 0;
}


             reply	other threads:[~2002-06-11 14:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-11  7:06 nikhild [this message]
2002-07-03 17:55 bkoz
2002-07-19  8:26 Nikhil R. Deshpande
2002-11-06 11:57 dje

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020611135615.32299.qmail@sources.redhat.com \
    --to=nikhild@flashmail.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).