Date: Wed, 16 Aug 2017 03:42:56 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-toolchain@FreeBSD.org Subject: [Bug 221423] gcc std::locale(LocaleName) crashes instead of throwing an exception Message-ID: <bug-221423-29464-eISif9dyiR@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-221423-29464@https.bugs.freebsd.org/bugzilla/> References: <bug-221423-29464@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221423 --- Comment #9 from Mark Millard <markmi@dsl-only.net> --- Here are lang/gcc7 and system clang compile/link results as viewed by ldd (all under head -r322287 in a Virtual Box virtual machine): things look good until I try my threading example. Then one combination fails (the -rpath one!). # g++7 -std=3Dc++14 -Wpedantic -Wall -Wl,-rpath=3D/usr/local/lib/gcc7 -O2 locale_failure_test.cc # ldd a.out a.out: libstdc++.so.6 =3D> /usr/local/lib/gcc7/libstdc++.so.6 (0x800824000) libm.so.5 =3D> /lib/libm.so.5 (0x800bb8000) libgcc_s.so.1 =3D> /usr/local/lib/gcc7/libgcc_s.so.1 (0x800de5000) libc.so.7 =3D> /lib/libc.so.7 (0x800ffc000) # ./a.out Note: The above did not crash but had no output. # g++7 -std=3Dc++14 -Wpedantic -Wall -O2 locale_failure_test.cc # ldd a.out a.out: libstdc++.so.6 =3D> /usr/local/lib/gcc7/libstdc++.so.6 (0x800824000) libm.so.5 =3D> /lib/libm.so.5 (0x800bb8000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x800de5000) libc.so.7 =3D> /lib/libc.so.7 (0x800ffb000) # ./a.out Note: The above did not crash but had no output. # clang++ -std=3Dc++14 -Wpedantic -Wall -O2 locale_failure_test.cc # ldd a.out a.out: libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x800824000) libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x800af0000) libm.so.5 =3D> /lib/libm.so.5 (0x800d0e000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x800f3b000) libc.so.7 =3D> /lib/libc.so.7 (0x801151000) # ./a.out Note: The above did not crash but had no output. Replacing the locale line with: std::locale l =3D std::locale("NOSUCH::en_US.UTF-8"); # g++7 -std=3Dc++14 -Wpedantic -Wall -Wl,-rpath=3D/usr/local/lib/gcc7 -O2 locale_failure_test.cc # ./a.out locale::facet::_S_create_c_locale name not valid # g++7 -std=3Dc++14 -Wpedantic -Wall -O2 locale_failure_test.cc # ./a.out locale::facet::_S_create_c_locale name not valid # ./a.out collate_byname<char>::collate_byname failed to construct for NOSUCH::en_US.UTF-8 So no exception was thrown in any of the examples and the code did not fail. Trying instead: # more exception_test.cc #include <exception> int main(void) { try { throw std::exception(); } catch (std::exception& e) {} return 0; } # g++7 -std=3Dc++14 -Wpedantic -Wall -Wl,-rpath=3D/usr/local/lib/gcc7 -O2 exception_test.cc # ./a.out # g++7 -std=3Dc++14 -Wpedantic -Wall -O2 exception_test.cc # ./a.out # clang++ -std=3Dc++14 -Wpedantic -Wall -O2 exception_test.cc # ./a.out So none of them fail. But trying my standard-C++ program that uses C++ threads: # g++7 -std=3Dc++14 -Wpedantic -Wall -pthread -Wl,-rpath=3D/usr/local/lib/g= cc7 -O2 cpp_clocks_investigation.cpp # ldd a.out a.out: libstdc++.so.6 =3D> /usr/local/lib/gcc7/libstdc++.so.6 (0x800844000) libm.so.5 =3D> /lib/libm.so.5 (0x800bd8000) libgcc_s.so.1 =3D> /usr/local/lib/gcc7/libgcc_s.so.1 (0x800e05000) libthr.so.3 =3D> /lib/libthr.so.3 (0x80101c000) libc.so.7 =3D> /lib/libc.so.7 (0x801244000) # ./a.out . . . (omitted) . . . Segmentation fault (core dumped) # g++7 -std=3Dc++14 -Wpedantic -Wall -pthread -O2 cpp_clocks_investigation.= cpp# ldd a.out a.out: libstdc++.so.6 =3D> /usr/local/lib/gcc7/libstdc++.so.6 (0x800844000) libm.so.5 =3D> /lib/libm.so.5 (0x800bd8000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x800e05000) libthr.so.3 =3D> /lib/libthr.so.3 (0x80101b000) libc.so.7 =3D> /lib/libc.so.7 (0x801243000) # ./a.out . . . (omitted) . . . End of clock tests. So it worked for /lib/libgcc_s.so.1 but not for /usr/local/lib/gcc7/libgcc_s.so.1 and I must have been wrong about /lib/libcxxrt.so.1 being what mattered. This threading example is a context where -Wl,-rpath=3D/usr/local/lib/gcc7 prevents correct operation because of cross library dependencies on implementation details of the build-time context vs. the mismatched runtime context for libthr.so.3 vs. libgcc_s.so.1 . # clang++ -std=3Dc++14 -Wpedantic -Wall -pthread -O2 cpp_clocks_investigati= on.cpp # ldd a.out a.out: libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x800844000) libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x800b10000) libm.so.5 =3D> /lib/libm.so.5 (0x800d2e000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x800f5b000) libthr.so.3 =3D> /lib/libthr.so.3 (0x801171000) libc.so.7 =3D> /lib/libc.so.7 (0x801399000) # ./a.out . . . (omitted) . . . End of clock tests. So this also worked. Again /lib/libthr.so.3 and /lib/libgcc_s.so.1 go together just fine. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-221423-29464-eISif9dyiR>