https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82366
Bug ID: 82366 Summary: std::regex constructor called from shared library throws std::bad_cast Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: spamdrop at fodvo dot org Target Milestone: --- Created attachment 42265 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42265&action=edit Included source code to the callback function, the .ii file I am writing a callback function in C++ that will be called from Oracle GoldenGate via the User Exit Function API; hence I don't have the source to the calling program. The code is linked in as a share lib .so module. My code (ggpost.cpp) in the attachment is about as simple a shared lib I can create, all it does is create the following lines: std::string test = "${foobar}"; std::smatch m; std::regex e ("\\$\\{[a-zA-Z_]+[a-zA-Z0-9_]*}"); bool foo = std::regex_search(test, m, e); std::cerr << "Foo = " << foo << endl; When the code is compiled against 7.1.0, and run from Oracle GG, is creates the following : terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted (core dumped) However, if I compile the same code in gcc 4.9.2, it works fine. Also I have attempted to construct my own calling program and I cannot duplicate the problem with either compiler. I have gathered as much detail as I can, but because it required OGG to duplicate the full problem, I'm handicapped providing all the information requested in the submission form. CUsrText is my attempt to create a local parent program to duplicate the problem, I include it, but it doesn't show the problem. Below is the detailed writeup, and an attachment is included with the code I can provide. ------------------------------------- Compile machine uname -r 2.6.32-642.15.1.el6.x86_64 gcc --version gcc (GCC) 7.1.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure lines: This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by configure, which was generated by GNU Autoconf 2.64. Invocation command line was $ ../gcc-7.1.0/configure --prefix=/dvl/odb/tools/gcc-7.1.0/ ## --------- ## ## Platform. ## ## --------- ## hostname = evdla176.delta.com uname -m = x86_64 uname -r = 2.6.32-642.15.1.el6.x86_64 uname -s = Linux uname -v = #1 SMP Mon Feb 20 02:26:38 EST 2017 Build of libggpost.so: make g++ -save-temps -fPIC -g -ggdb -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -Wnon-virtual-dtor -ggdb -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 -DTIXML_USE_STL -D_LINUX_ -fpermissive -std=c++11 -I/. -I/usr/include/ -I/../../include -I/home/b/bfoddy/odb5/dev/cc/snapshots/a26811_snap_linux.4/vobs/soc/include -c ggpost.cpp -o ggpost.o evdla176:/home/b/bfoddy/odb5/dev/cc/snapshots/a26811_snap_linux.4/vobs/soc/ODB/goldengate > g++ -fPIC -save-temps ggpost.o -o libggpost.so -shared evdla176:/home/b/bfoddy/odb5/dev/cc/snapshots/a26811_snap_linux.4/vobs/soc/ODB/goldengate > ll *.i* -rw-r--r-- 1 545165 dtdev 1653968 Sep 29 18:04 ggpost.ii ll libggpost.so -rwxr-xr-x 1 545165 dtdev 1956286 Sep 29 18:05 libggpost.so evdla176:/home/b/bfoddy/odb5/dev/cc/snapshots/a26811_snap_linux.4/vobs/soc/ODB/goldengate > ldd libggpost.so linux-vdso.so.1 => (0x00007ffd4eff0000) libstdc++.so.6 => /dvl/odb/tools/gcc-7.1.0/lib64/libstdc++.so.6 (0x00007f4e72248000) libm.so.6 => /lib64/libm.so.6 (0x00007f4e71faf000) libgcc_s.so.1 => /dvl/odb/tools/gcc-7.1.0/lib64/libgcc_s.so.1 (0x00007f4e71d99000) libc.so.6 => /lib64/libc.so.6 (0x00007f4e71a05000) /lib64/ld-linux-x86-64.so.2 (0x00007f4e7287f000) If I use my CUsrExitText program, no problem. ./CUsrExitText Start , open DL Open success. Calling lib Foo = 1 Now copy libggpost.so to runtime machine where Oracle GG installed. from runtime machine: uname -r 2.6.32-431.el6.x86_64 [omsd@evdla078 JMS_Adapter]$ ldd libggpost.so linux-vdso.so.1 => (0x00007fff855ff000) libstdc++.so.6 => /dvl/oms6/gcc-7.1.0/lib64/libstdc++.so.6 (0x00007fc4dc023000) libm.so.6 => /lib64/libm.so.6 (0x00007fc4dbd8e000) libgcc_s.so.1 => /dvl/oms6/gcc-7.1.0/lib64/libgcc_s.so.1 (0x00007fc4dbb78000) libc.so.6 => /lib64/libc.so.6 (0x00007fc4db7e4000) /lib64/ld-linux-x86-64.so.2 (0x00007fc4dc65a000) Now run the Oracle GG Extract program, which is configured to open libggpost.so and call the function CUSEREXIT with EXIT_CALL_START as its first argument. ./extract PARAMFILE ./dirprm/foddyue.prm *********************************************************************** Oracle GoldenGate Capture Version 12.2.0.1.160419 OGGCORE_12.2.0.1.0OGGBP_PLATFORMS_160430.1401 Linux, x64, 64bit (optimized), Generic on Apr 30 2016 17:32:41 Copyright (C) 1995, 2016, Oracle and/or its affiliates. All rights reserved. Starting at 2017-09-29 18:23:38 *********************************************************************** Operating System Version: Linux Version #1 SMP Sun Nov 10 22:19:54 EST 2013, Release 2.6.32-431.el6.x86_64 Node: evdla078.delta.com Machine: x86_64 soft limit hard limit Address Space Size : unlimited unlimited Heap Size : unlimited unlimited File Size : unlimited unlimited CPU Time : unlimited unlimited Process id: 17780 Description: *********************************************************************** ** Running with the following parameters ** *********************************************************************** 2017-09-29 18:23:38 INFO OGG-03059 Operating system character set identified as UTF-8. 2017-09-29 18:23:38 INFO OGG-02695 ANSI SQL parameter syntax is used for parameter parsing. Extract foddyue GETENV(LD_LIBRARY_PATH) LD_LIBRARY_PATH = :/dvl/oms6/OracleGG/JMS_Adapter:/dvl/oms6/OracleGG/JDK/jdk1.8.0_144//jre/lib/amd64/server:/dvl/oms6/gcc-7.1.0/lib64:/opt/mqm/lib64 SourceDefs dirdef/jmsrep.def CUserExit libggpost.so CUSEREXIT PassThru IncludeUpdateBefores 2017-09-29 18:23:38 INFO OGG-04523 ./extract running with user exit library libggpost.so, compatiblity level (4) is not current, using compatiblity level (1). 2017-09-29 18:23:38 INFO OGG-04526 ./extract running with user exit library libggpost.so. Current session character set is operating system default character set. GetUpdateBefores Table ODB_PRIMARY.*; 2017-09-29 18:23:38 INFO OGG-01851 filecaching started: thread ID: 139767519692544. 2017-09-29 18:23:38 INFO OGG-01815 Virtual Memory Facilities for: COM anon alloc: mmap(MAP_ANON) anon free: munmap file alloc: mmap(MAP_SHARED) file free: munmap target directories: /dvl/oms6/OracleGG/JMS_Adapter/dirtmp. CACHEMGR virtual memory values (may have been adjusted) CACHEPAGEOUTSIZE (default): 8M PROCESS VM AVAIL FROM OS (min): 128G CACHESIZEMAX (strict force to disk): 96G CACHEVMPAGEOUTMAX: 64M terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted (core dumped) Since a core was created, I'm including the gdb stacktrace. gdb extract core.17780 GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1) Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/extract...done. [New Thread 17780] [New Thread 17784] [New Thread 17783] [New Thread 17781] [New Thread 17782] [New Thread 17785] Missing separate debuginfo for Try: yum --disablerepo='*' --enablerepo='*-debug*' install /usr/lib/debug/.build-id/81/a81be2e44c93640adedb62adc93a47f4a09dd1 Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done. Loaded symbols for /lib64/librt.so.1 Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done. Loaded symbols for /lib64/libdl.so.2 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libggparam.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libggparam.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libgglog.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libgglog.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libggrepo.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libggrepo.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libdb-6.1.so...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libdb-6.1.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libggperf.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libggperf.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libicui18n.so.48...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libicui18n.so.48 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libicuuc.so.48...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libicuuc.so.48 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libicudata.so.48...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libicudata.so.48 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libxerces-c.so.28...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libxerces-c.so.28 Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done. [Thread debugging using libthread_db enabled] Loaded symbols for /lib64/libpthread.so.0 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libantlr3c.so...(no debugging symbols found)...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libantlr3c.so Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libggnnzitp.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libggnnzitp.so Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done. Loaded symbols for /lib64/libm.so.6 Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done. Loaded symbols for /lib64/libc.so.6 Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done. Loaded symbols for /lib64/ld-linux-x86-64.so.2 Reading symbols from /dvl/oms6/gcc-7.1.0/lib64/libstdc++.so.6...done. Loaded symbols for /dvl/oms6/gcc-7.1.0/lib64/libstdc++.so.6 Reading symbols from /dvl/oms6/gcc-7.1.0/lib64/libgcc_s.so.1...done. Loaded symbols for /dvl/oms6/gcc-7.1.0/lib64/libgcc_s.so.1 Reading symbols from /dvl/oms6/OracleGG/JMS_Adapter/libggpost.so...done. Loaded symbols for /dvl/oms6/OracleGG/JMS_Adapter/libggpost.so Reading symbols from /lib64/libnss_files.so.2...(no debugging symbols found)...done. Loaded symbols for /lib64/libnss_files.so.2 Core was generated by `./extract PARAMFILE ./dirprm/foddyue.prm'. Program terminated with signal 6, Aborted. #0 0x00007f1e2c814625 in raise () from /lib64/libc.so.6 warning: File "/dvl/oms6/gcc-7.1.0/lib64/libstdc++.so.6.0.23-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "/usr/share/gdb/auto-load:/usr/lib/debug:/usr/bin/mono-gdb.py". To enable execution of this file add add-auto-load-safe-path /dvl/oms6/gcc-7.1.0/lib64/libstdc++.so.6.0.23-gdb.py line to your configuration file "/dvl/oms5/home/omsd/.gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "/dvl/oms5/home/omsd/.gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: info "(gdb)Auto-loading safe path" Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6_6.5.x86_64 (gdb) where #0 0x00007f1e2c814625 in raise () from /lib64/libc.so.6 #1 0x00007f1e2c815e05 in abort () from /lib64/libc.so.6 #2 0x00007f1e30c81c6d in __gnu_cxx::__verbose_terminate_handler () at ../../.././libstdc++-v3/libsupc++/vterminate.cc:95 #3 0x00007f1e30c82226 in __cxxabiv1::__terminate (handler=Unhandled dwarf expression opcode 0xf3 ) at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:40 #4 0x00007f1e30c82253 in std::terminate () at ../../.././libstdc++-v3/libsupc++/eh_terminate.cc:50 #5 0x00007f1e30c79723 in __cxxabiv1::__cxa_throw (obj=0x2a339d0, tinfo=0x7f1e30eeb170, dest=0x7f1e30c86450 <std::bad_cast::~bad_cast()>) at ../../.././libstdc++-v3/libsupc++/eh_throw.cc:86 #6 0x00007f1e30c85c82 in std::__throw_bad_cast () at ../../../.././libstdc++-v3/src/c++11/functexcept.cc:58 #7 0x00007f1e2c5308c7 in std::__cxx11::collate<char> const& std::use_facet<std::__cxx11::collate<char> >(std::locale const&) () at /dvl/odb5/build/gcc-7.1.0.obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/locale_classes.tcc:137 #8 0x00007f1e2964c897 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::__cxx11::regex_traits<char>::transform<char*>(char*, char*) const () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex.h:233 #9 0x00007f1e2964a2b4 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::__cxx11::regex_traits<char>::transform_primary<char const*>(char const*, char const*) const () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex.h:266 #10 0x00007f1e296458f7 in std::__detail::_BracketMatcher<std::__cxx11::regex_traits<char>, false, false>::_M_apply(char, std::integral_constant<bool, false>) const::{lambda()#1}::operator()() const () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:626 #11 0x00007f1e29645a78 in std::__detail::_BracketMatcher<std::__cxx11::regex_traits<char>, false, false>::_M_apply(char, std::integral_constant<bool, false>) const () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:634 #12 0x00007f1e296411e7 in std::__detail::_BracketMatcher<std::__cxx11::regex_traits<char>, false, false>::_M_make_cache(std::integral_constant<bool, true>) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.h:555 #13 0x00007f1e2963d484 in std::__detail::_BracketMatcher<std::__cxx11::regex_traits<char>, false, false>::_M_ready() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.h:524 #14 0x00007f1e2963e096 in void std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_insert_bracket_matcher<false, false>(bool) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:444 #15 0x00007f1e2963aa77 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_bracket_expression() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:363 #16 0x00007f1e296364a8 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_atom() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:349 #17 0x00007f1e29633685 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_term() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:139 #18 0x00007f1e296313c9 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_alternative() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:121 #19 0x00007f1e296313ec in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_alternative() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:124 #20 0x00007f1e296313ec in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_alternative() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:124 #21 0x00007f1e2962fb71 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_M_disjunction() () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:97 #22 0x00007f1e2962ef64 in std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_Compiler(char const*, char const*, std::locale const&, std::regex_constants::syntax_option_type) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.tcc:82 #23 0x00007f1e2962e397 in std::enable_if<std::__detail::__is_contiguous_normal_iter<char const*>::value, std::shared_ptr<std::__detail::_NFA<std::__cxx11::regex_traits<char> > const> >::type std::__detail::__compile_nfa<char const*, std::__cxx11::regex_traits<char> >(char const*, char const*, std::__cxx11::regex_traits<char>::locale_type const&, std::regex_constants::syntax_option_type) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex_compiler.h:203 #24 0x00007f1e2962db1d in std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::basic_regex<char const*>(char const*, char const*, std::locale, std::regex_constants::syntax_option_type) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex.h:769 #25 0x00007f1e2962d794 in std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::basic_regex<char const*>(char const*, char const*, std::regex_constants::syntax_option_type) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex.h:512 #26 0x00007f1e2962d474 in std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::basic_regex(char const*, std::regex_constants::syntax_option_type) () at /dvl/odb/tools/gcc-7.1.0/include/c++/7.1.0/bits/regex.h:445 #27 0x00007f1e2962c647 in CUSEREXIT () at ggpost.cpp:44 #28 0x0000000000591f4a in call_user_exit_routine (call_type=1) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/app/er/userexit.c:825 #29 call_user_exit_routine (call_type=1) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/app/er/userexit.c:807 #30 0x00000000005f0e43 in extract_main (argc=Unhandled dwarf expression opcode 0xf3 ) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/app/er/extract/extract.cpp:826 #31 0x000000000074db96 in ggs::gglib::MultiThreading::MainThread::ExecMain (this=0x7fff47e75370) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/gglib/ggstd/MultiThreading.cpp:1305 #32 0x0000000000751fc7 in ggs::gglib::MultiThreading::Thread::RunThread(struct {...} *) (threadArgs=Unhandled dwarf expression opcode 0xf3 ) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/gglib/ggstd/MultiThreading.cpp:499 ---Type <return> to continue, or q <return> to quit--- #33 0x00000000007525dd in ggs::gglib::MultiThreading::MainThread::Run (this=Unhandled dwarf expression opcode 0xf3 ) at /scratch/aime/adestore/views/aime_adc4150338/oggcore/OpenSys/src/gglib/ggstd/MultiThreading.cpp:1296 #34 0x00000000005f1d4b in main () The full core file is available on request. I've given as much supporting info as I can, hopefully its enough.