public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Irfan Adilovic <irfanadilovic@gmail.com>
To: cygwin@cygwin.com
Subject: gcc-7.1.0/c++17/old-abi: empty stringstream invalid memory access
Date: Sun, 23 Jul 2017 12:32:00 -0000	[thread overview]
Message-ID: <CAJoYywWYpcOPDCsjTBz0jDnsTvqzB=Bx3m-E7Bpxc72BM8=RGw@mail.gmail.com> (raw)

I am reproducing here a bug report I filed to gcc's bugzilla against
gcc-7.1.0: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81522 , in
hopes of finding others who observed the same issue or who may have a
solution. The bug only appears on Cygwin and only in c++17 mode with
the old ABI.

-- Irfan

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

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

             reply	other threads:[~2017-07-23 11:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23 12:32 Irfan Adilovic [this message]
2017-07-23 15:59 ` Dan Kegel
2017-07-24  2:09 ` David Stacey

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='CAJoYywWYpcOPDCsjTBz0jDnsTvqzB=Bx3m-E7Bpxc72BM8=RGw@mail.gmail.com' \
    --to=irfanadilovic@gmail.com \
    --cc=cygwin@cygwin.com \
    /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).