Bug 70459 - regex segfault on long sequences
Summary: regex segfault on long sequences
Status: RESOLVED DUPLICATE of bug 61582
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-30 14:25 UTC by chaoskeeper
Modified: 2016-03-31 04:27 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Minimal test case (276 bytes, text/x-csrc)
2016-03-30 14:28 UTC, chaoskeeper
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chaoskeeper 2016-03-30 14:25:33 UTC
A detailed description and tests are given at SO (http://stackoverflow.com/questions/36304204/%D0%A1-regex-segfault-on-long-sequences), in short

std::regex r("\\s+");
std::string out = std::regex_replace(cstring, r, " ");

crashes with SIGSEGV on strings with long space sequences (-O3 can handle around 20k spaces, -O0 handles 12k). Clang produce similar results. Switching to libc++ cures the crashes.


Crash dump shows lengthy stack (35k frames) of 

std::__detail::_Executor<char*, std::allocator<std::__cxx11::sub_match<char*> >, std::__cxx11::regex_traits<char>, true>::_M_dfs

calls.


GCC:

Configured with: /build/gcc-multilib/src/gcc-5-20160209/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 5.3.0 (GCC)
Comment 1 chaoskeeper 2016-03-30 14:28:14 UTC
Created attachment 38132 [details]
Minimal test case
Comment 2 Tim Shen 2016-03-31 04:27:16 UTC
This is a known issue. I plan to fix it, but it's not going to be in GCC 6.

Thanks for reporting!

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