This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/14651] New: Segfault while using stringstream


Hello everyone ...

- Here is the bug: Using a stringstream on a Sparc Solaris 2 makes
  the program crash with a Segmentation Fault. 

  However, the problem seems to occur only with g++ 3.x or the libstdc++.5.x.
  This works well with gcc 2.95.3 and/or libstdc++.so.2.10.0, and on a PC host
  running GNU/Linux-gcc3.2-libstdc++.so.5 .

- Here is the piece of code:

testnul.cpp:
#include <iostream>
#include <sstream>

using namespace std;

int main (void)
{
  string        s;
  stringstream  t;

  t << "Hello";
  t >> s;

  cout << s << endl;

  return 0;
}

- Let's try:

$ uname -a
SunOS myname 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-4
$ g++ --version
g++ (GCC) 3.1
$ g++ testnul.cpp -o testnul
$ ldd testnul
libstdc++.so.5 => /usr/local/lib/libstdc++.so.5
libm.so.1      => /usr/lib/libm.so.1
libgcc_s.so.1  => /usr/local/lib/libgcc_s.so.1
libc.so.1      => /usr/lib/libc.so.1
libdl.so.1     => /usr/lib/libdl.so.1
/usr/platform/SUNW,Ultra-4/lib/libc_psr.so.1
$ ./testnul
Segmentation Fault

- I also get a segfault if I disable the string insertion:

testnul.cpp:
#include <iostream>
#include <sstream>

using namespace std;

int main (void)
{
  string        s;
  stringstream  t;

  t << "Hello";
//  t >> s;

  cout << "That's all folks" << endl;

  return 0;
}

$ g++ testnul.cpp -o testnul
$ ./testnul
That's all folks
Segmentation Fault

- This time, the object seems to crash at destruction time.
- Finally, the program stops crashing if I also comment the string
  declaration. However, it won't crash neither if I don't use a stringstream
  at all and fill the string with "cin >> s".

- I thought it could comes from this bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=6784 , so I recompiled the libstdc++
from the latest GCC release (3.3.3) and built the libstdc++.so.5.0.5, but it
didn't help. I couldn't rebuild the whole compiler because of a slight lack of
space to perform a complete GCC bootstrap.

Thanks you in advance !

-- 
           Summary: Segfault while using stringstream
           Product: gcc
           Version: 3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvandenbroeck at free dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-solaris2
  GCC host triplet: sparc-solaris2
GCC target triplet: sparc-solaris2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14651


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]