[Bug libstdc++/84865] New: Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 Bug ID: 84865 Summary: Regular expression regex_search falls into infinite loop causing segfault on crayxc machines Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: shaoqin2 at illinois dot edu Target Milestone: --- Using regex_search in a multi threaded environment on crayxc super computer will cause infinite loop and segfault. g++ information is here Target: x86_64-suse-linux Configured with: ../cray-gcc-5.3.0/configure --prefix=/opt/gcc/5.3.0/snos --disable-nls --libdir=/opt/gcc/5.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/5.3.0/snos/include/g++ --with-slibdir=/opt/gcc/5.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog Thread model: posix gcc version 5.3.0 20151204 (Cray Inc.) (GCC) uname -a Linux edison11 4.4.103-92.56-default #1 SMP Wed Dec 27 16:24:31 UTC 2017 (2fd2155) x86_64 x86_64 x86_64 GNU/Linux Command line to reproduce this segfault: (.cpp file is not attached per guideline. Feel free to ask me to post it, it's super short and simple, I extracted minimum error reproducing code) g++ -std=c++11 -save-temps regex.cpp -lpthread ./a.out Segmentation fault (core dumped)
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 --- Comment #1 from Bobby Lu --- No compiler warning is generated
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 --- Comment #3 from Bobby Lu --- Created attachment 43659 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43659&action=edit Single source file to reproduce the bug compile with g++ -std=c++11 regex.cpp -lpthread ./a.out Segmentation fault (core dumped) g++ -v Using built-in specs. COLLECT_GCC=/opt/gcc/7.1.0/bin/../snos/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc/7.1.0/snos/libexec/gcc/x86_64-suse-linux/7.1.0/lto-wrapper Target: x86_64-suse-linux Configured with: ../cray-gcc-7.1.0-201705230545.65f29659747b4/configure --prefix=/opt/gcc/7.1.0/snos --disable-nls --libdir=/opt/gcc/7.1.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.1.0/snos/include/g++ --with-slibdir=/opt/gcc/7.1.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib Thread model: posix gcc version 7.1.0 20170502 (Cray Inc.) (GCC) uname -a Linux edison03 4.4.103-92.56-default #1 SMP Wed Dec 27 16:24:31 UTC 2017 (2fd2155) x86_64 x86_64 x86_64 GNU/Linux
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 Bobby Lu changed: What|Removed |Added Attachment #43659|0 |1 is obsolete|| --- Comment #4 from Bobby Lu --- Created attachment 43660 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43660&action=edit Correction to the previous file. That was the gcc5.4 reproduction source. Sorry Single source file to reproduce the bug. This is the one for gcc-7.1.0. I uploaded a wrong one. Sorry for the confusion. compile with g++ -std=c++11 regex.cpp -lpthread ./a.out Segmentation fault (core dumped) g++ -v Using built-in specs. COLLECT_GCC=/opt/gcc/7.1.0/bin/../snos/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc/7.1.0/snos/libexec/gcc/x86_64-suse-linux/7.1.0/lto-wrapper Target: x86_64-suse-linux Configured with: ../cray-gcc-7.1.0-201705230545.65f29659747b4/configure --prefix=/opt/gcc/7.1.0/snos --disable-nls --libdir=/opt/gcc/7.1.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.1.0/snos/include/g++ --with-slibdir=/opt/gcc/7.1.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib Thread model: posix gcc version 7.1.0 20170502 (Cray Inc.) (GCC) uname -a Linux edison03 4.4.103-92.56-default #1 SMP Wed Dec 27 16:24:31 UTC 2017 (2fd2155) x86_64 x86_64 x86_64 GNU/Linux
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 --- Comment #7 from Bobby Lu --- Created attachment 43661 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43661&action=edit Gdb stack trace. $ ulimit unlimited
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 Bobby Lu changed: What|Removed |Added Attachment #43661|0 |1 is obsolete|| --- Comment #8 from Bobby Lu --- Created attachment 43662 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43662&action=edit longer GDB stack trace longer GDB stack trace. The rest is the same just overflows and segfault
[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865 --- Comment #11 from Bobby Lu --- (In reply to Tim Shen from comment #9) > I see. Can you show the ulimit *stack* information? I believe it's -s. > > Also, try -O2 so that the functions are inlined. > > As for the stack overflow, it's a known issue. To workaround this, please > set a bigger stack size. $ ulimit -s unlimited -O2 resolves the issue. Thank you very much! So basically the issue can be explained as recursive call not being optimized out. Thus stack overflows is expected? This explains everything actually. I was trying to control so many different possible things and reproducing the bug. Removing random string parts would resolve it issue sometime, which now is just due to string is shorter thus stack needed is smaller?