You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2007/06/08 17:35:28 UTC

[jira] Commented: (STDCXX-427) SIGSEGV in istringstream::str()

    [ https://issues.apache.org/jira/browse/STDCXX-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12502845 ] 

Farid Zaripov commented on STDCXX-427:
--------------------------------------

Another test case:

#include <cassert>
#include <cstdio>
#include <sstream>

int main ()
{
    struct Buf: std::stringbuf {
        Buf (std::string s, std::ios::openmode m)
            : std::stringbuf (s, m) { }

        void setget (int beg, int cur, int end) {
            setg (eback () + beg, eback () + cur, eback () + end);
        }

        void setput (int beg, int cur, int end) {
            setp (pbase () + beg, pbase () + end);
            pbump (cur);
        }
    };

    {
        Buf buf ("abcde", std::ios::in);
        buf.setget (1, 2, 4);
        std::printf ("%s\n", buf.str ().c_str ());
        assert ("bcd" == buf.str ());
    }
    {
        Buf buf ("abcde", std::ios::out);
        buf.setput (1, 2, 4);
        std::printf ("%s\n", buf.str ().c_str ());
        assert ("bcde" == buf.str ());
    }
    {
        Buf buf ("abcde", std::ios::openmode ());
        std::printf ("%s\n", buf.str ().c_str ());
        assert ("" == buf.str ());
    }
}


> SIGSEGV in istringstream::str()
> -------------------------------
>
>                 Key: STDCXX-427
>                 URL: https://issues.apache.org/jira/browse/STDCXX-427
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 27. Input/Output
>    Affects Versions: 4.2
>         Environment: gcc-3.3.3 on Linux
>            Reporter: Martin Sebor
>            Assignee: Farid Zaripov
>            Priority: Critical
>             Fix For: 4.2
>
>
> This only happens on trunk, not with 4.1.3:
> $ rm t.o && cat t.cpp && make t && gdb -q t
> #include <cassert>
> #include <sstream>
> #include <string>
> int main ()
> {
>     using namespace std;
>     string str ("test");
>     
>     istringstream isstr;
>     
>     isstr.str (str);
>     assert (isstr.str ().length () == str.length ());
>     assert (isstr.str () == str);
> }
> gcc -c -I/amd/devco/sebor/stdcxx/include/ansi -D_RWSTDDEBUG   -pthread -I/amd/devco/sebor/stdcxx/include -I/build/sebor/stdcxx-gcc-3.3.3_43.41-15s/include -I/amd/devco/sebor/stdcxx/examples/include  -pedantic -nostdinc++ -g  -m32 -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align   t.cpp
> gcc t.o -o t -pthread -m32 -L/build/sebor/stdcxx-gcc-3.3.3_43.41-15s/lib  -lstd15s -lsupc++ -lm 
> Using host libthread_db library "/lib64/tls/libthread_db.so.1".
> (gdb) r
> Starting program: /build/sebor/stdcxx-gcc-3.3.3_43.41-15s/examples/t 
> [Thread debugging using libthread_db enabled]
> [New Thread 1433271616 (LWP 12696)]
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1433271616 (LWP 12696)]
> 0x0804eb4c in __rw::__rw_memcpy (dst=0x556e1014, src=0x80900a0, 
>     nbytes=134672708) at /amd/devco/sebor/stdcxx/src/string.cpp:42
> 42              *tmp++ = *csrc++;
> (gdb) where
> #0  0x0804eb4c in __rw::__rw_memcpy (dst=0x556e1014, src=0x80900a0, 
>     nbytes=134672708) at /amd/devco/sebor/stdcxx/src/string.cpp:42
> #1  0x08053781 in std::char_traits<char>::copy (__dst=0x556e1014 "test", 
>     __src=0x80900a0 "test", __n=134807716) at _traits.h:425
> #2  0x080562ec in basic_string (this=0xffffd0d0, __s=0x80900a0 "test", 
>     __n=134807716, __alloc=@0xffffcfc0) at string.cc:185
> #3  0x0805dac5 in std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str (this=0xffffd048) at sstream:130
> #4  0x08049bc9 in std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::str (this=0xffffd040) at sstream:268
> #5  0x0804994d in main () at t.cpp:15

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.