Bug 81522 - c++17/old-abi/cygwin empty stringstream invalid memory access
Summary: c++17/old-abi/cygwin empty stringstream invalid memory access
Status: RESOLVED DUPLICATE of bug 86138
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 7.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-23 09:42 UTC by Irfan Adilovic
Modified: 2018-06-19 21:47 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build: x86_64-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Irfan Adilovic 2017-07-23 09:42:43 UTC
This trivial program:

#include <sstream>
int main() {
    std::stringstream os; // same with ("") or (std::string())
    os.str();
    return 0;
}

causes an invalid memory access with gcc 7.1.0 (compiled from source), but only on Cygwin in c++17 mode with old ABI, and only if the stringstream is constructed empty. Changing any of those parameters no longer causes the issue.

Thread 1 "string" received signal SIGABRT, Aborted.
0x00000001004018a0 in __gnu_cxx::new_allocator<char>::deallocate (this=0x6, __p=0x3e8000003fc <error: Cannot access memory at address 0x3e8000003fc>)
    at /usr/local/gcc-7.1.0/include/c++/7.1.0/ext/new_allocator.h:125
125             ::operator delete(__p);
(gdb) bt
#0  0x00000001004018a0 in __gnu_cxx::new_allocator<char>::deallocate (this=0x6, __p=0x3e8000003fc <error: Cannot access memory at address 0x3e8000003fc>)
    at /usr/local/gcc-7.1.0/include/c++/7.1.0/ext/new_allocator.h:125
#1  0x00000001800b25d2 in CreateEventW () from /usr/bin/cygwin1.dll
#2  0x0000000000000130 in ?? ()

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-7.1.0/libexec/gcc/x86_64-pc-cygwin/7.1.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: ../configure --prefix=/usr/local/gcc-7.1.0 --enable-threads=posix --enable-checking=release --enable-languages=c,c++ --build=x86_64-pc-cygwin --disable-multilib --with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 7.1.0 (GCC)

Sample program compiled with:

$ g++  -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0 -ggdb -O0   string.cc   -o string
Comment 1 Jonathan Wakely 2018-05-14 13:47:53 UTC
Possibly related to PR 82172 (which was due to a binutils bug) but that apparently only occurs when using LTO.
Comment 2 Jonathan Wakely 2018-06-19 21:47:25 UTC
Looks like Bug 86138

*** This bug has been marked as a duplicate of bug 86138 ***