[Bug libstdc++/39569] New: Apparent memory corruption in std::stringstream after calling syslog()

jmcdonald at fairfield dot com gcc-bugzilla@gcc.gnu.org
Fri Mar 27 21:53:00 GMT 2009


Good afternoon,

I've encountered a memory corruption problem writing to a stringstream after
I've called syslog(), and I've been unable to find resolution.  

The short summary is that if my program makes a call to syslog(), then later
during execution when I write >136 bytes of data into an std::stringstream
object, the first 4 bytes in the stream get written as (or reset to) 0's.  (If
I write only 132 bytes into the object, the stream doesn't get corrupt.  If I
don't make the call to syslog(), the stream doesn't get corrupted.)

I've created a small, self-contained test app that seems to reliably recreate
the bug.  I have tested (and recreated) it under Fedora 8 (x86_64), Fedora 8
(ppc), and Fedora 10 (i386).  (I tried different compilers & platforms to try
and rule out problems with a particular installation/configuration.)  I can
make available a .tgz file containing this test app upon request.

My apologies in advance for any mistakes I make in submitting the bug... this
is my first gcc bug, so I'm unfamiliar with the process.

The remainder of the requested Bug info:
  Exact GCC version: gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC)
  System Type:       Target: i386-redhat-linux
  GCC build options: Configured with: ../configure --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-cpu=generic --build=i386-redhat-linux

  Command line which triggers bug:  
           make             # to generate test_main;
           ./test_main 1    # to run the program and write to syslog
    Note: you can also enter "./test_main 0" to run writing with printf instead
of syslog... this will not fail.

  Compiler output: 
        g++ -c -O0 -g -Wall -save-temps  test_main.cpp 
        g++ -c -O0 -g -Wall -save-temps  FfdDevice.cpp 
        g++ -c -O0 -g -Wall -save-temps  FfdDataPage.cpp 
        g++ -c -O0 -g -Wall -save-temps  Trace.cpp 
        gcc -c -O0 -g -Wall -save-temps  BoxLog.c 
        g++  -o test_main test_main.o FfdDevice.o FfdDataPage.o Trace.o
BoxLog.o  -lstdc++

  Preprocessed *.i* files:   Hmm... you have me here... I don't see a way to
attach them, or the source files themselves, to the Bugzilla bug.  I will
commit the bug and then see if some mechanism for attaching a .tgz with the
sources and .i* files.  If I can't find a way, then I will be happy to provide
the .i* files and/or sources upon request, if someone will let me know the
proper mechanism.


-- 
           Summary: Apparent memory corruption in std::stringstream after
                    calling syslog()
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jmcdonald at fairfield dot com


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



More information about the Gcc-bugs mailing list