Date: Fri, 02 Sep 2016 12:17:42 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-ports-bugs@FreeBSD.org Subject: [Bug 212330] lang/gcc6: armv6 g++ 6.2.0 compiled ~10 line std::async using program gets SIGSEGV (but amd64 works) Message-ID: <bug-212330-13@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D212330 Bug ID: 212330 Summary: lang/gcc6: armv6 g++ 6.2.0 compiled ~10 line std::async using program gets SIGSEGV (but amd64 works) Product: Ports & Packages Version: Latest Hardware: arm OS: Any Status: New Severity: Affects Only Me Priority: --- Component: Individual Port(s) Assignee: gerald@FreeBSD.org Reporter: markmi@dsl-only.net Assignee: gerald@FreeBSD.org Flags: maintainer-feedback?(gerald@FreeBSD.org) The following ~10 line program also shows the SIGSEGV behavior on armv6 (an rpi2) for running ./a.out after compiling via g++6. built with the system clang++ 3.8.0 does not have such problems. The program is a vast simplifica= tion of the original program that the crash was first discovered with. # more g++6_build_crashes.cpp=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 #include <future> // future, asy= nc, launch::async static void f() {} int main(int, const char* []) { auto a0{ std::async( std::launch::async, f ) }; a0.get(); return 0; } # /usr/local/bin/gdb a.out=20 GNU gdb (GDB) 7.11.1 [GDB v7.11.1 for FreeBSD] . . . (gdb) run Starting program: /root/c_tests/a.out=20 [New LWP 100188 of process 2253] Thread 2 received signal SIGSEGV, Segmentation fault. [Switching to LWP 100188 of process 2253] 0x00000000 in ?? () (gdb) info threads Id Target Id Frame=20 1 LWP 100172 of process 2253 0x00000000 in ?? () * 2 LWP 100188 of process 2253 0x00000000 in ?? () (gdb) thread 1 [Switching to thread 1 (LWP 100172 of process 2253)] #0 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x200b8acc in _pthread_once (once_control=3D<optimized out>, init_routine=3D<optimized out>) at /usr/src/lib/libthr/thread/thr_once.c:95 #2 0x00011b14 in __gthread_once (__once=3D0x20824030, __func=3D0x11660 <__once_proxy@plt>) at /usr/local/lib/gcc6/include/c++/armv6-portbld-freebsd11.0/bits/gthr-default= .h:699 #3 0x0001440c in std::call_once<void (std::thread::*)(), std::thread*>(std::once_flag&, void (std::thread::*&&)(), std::thread*&&) (__once=3D...,=20 __f=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x11213>, __args#0=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x11207>) at /usr/local/lib/gcc6/include/c++/mutex:619 #4 0x00013004 in std::__future_base::_Async_state_commonV2::_M_join (this=3D0x2082400c) at /usr/local/lib/gcc6/include/c++/future:1644 #5 0x00012fb4 in std::__future_base::_Async_state_commonV2::_M_complete_as= ync (this=3D0x2082400c) at /usr/local/lib/gcc6/include/c++/future:1642 #6 0x000128ac in std::__future_base::_State_baseV2::wait (this=3D0x2082400= c) at /usr/local/lib/gcc6/include/c++/future:325 #7 0x00013b3c in std::__basic_future<void>::_M_get_result (this=3D0xbfbfed= 38) at /usr/local/lib/gcc6/include/c++/future:687 #8 0x00012ec4 in std::future<void>::get (this=3D0xbfbfed38) at /usr/local/lib/gcc6/include/c++/future:852 #9 0x00011df4 in main () at g++6_build_crashes.cpp:8 (gdb) thread 2 [Switching to thread 2 (LWP 100188 of process 2253)] #0 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x200b8acc in _pthread_once (once_control=3D<optimized out>, init_routine=3D<optimized out>) at /usr/src/lib/libthr/thread/thr_once.c:95 #2 0x00011b14 in __gthread_once (__once=3D0x20824024, __func=3D0x11660 <__once_proxy@plt>) at /usr/local/lib/gcc6/include/c++/armv6-portbld-freebsd11.0/bits/gthr-default= .h:699 #3 0x00013718 in std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::_= _future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), s td::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, v= oid (std::__future_base::_ State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Resul= t_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::un ique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) (__once=3D..., __f=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x10fad>,=20 __args#0=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x10c41>, __args#1=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x10f95>,=20 __args#2=3D<unknown type in /root/c_tests/a.out, CU 0x0, DIE 0x10fa1>) = at /usr/local/lib/gcc6/include/c++/mutex:619 #4 0x000129c4 in std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_= ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) ( this=3D0x2082400c, __res=3D..., __ignore_failure=3Dfalse) at /usr/local/lib/gcc6/include/c++/future:393 #5 0x00017b6c in std::__future_base::_Async_state_impl<std::_Bind_simple<v= oid (*())()>, void>::_Async_state_impl(std::_Bind_simple<void (*())()>&&)::{lambda()#1}::operator()() const () at /usr/local/lib/gcc6/include/c++/future:1664 #6 0x00019430 in std::_Bind_simple<std::__future_base::_Async_state_impl<std::_Bind_simple<v= oid (*())()>, void>::_Async_state_impl(std::_Bind_simple<void (*())()>&&)::{lambda()#1} ()>::_M_invoke<>(st d::_Index_tuple<>) (this=3D0x2082500c) at /usr/local/lib/gcc6/include/c++/functional:1400 #7 0x000192f4 in std::_Bind_simple<std::__future_base::_Async_state_impl<std::_Bind_simple<v= oid (*())()>, void>::_Async_state_impl(std::_Bind_simple<void (*())()>&&)::{lambda()#1} ()>::operator()() (this=3D0x2082500c) at /usr/local/lib/gcc6/include/c++/functional:1389 #8 0x00018e68 in std::thread::_State_impl<std::_Bind_simple<std::__future_base::_Async_state= _impl<std::_Bind_simple<void (*())()>, void>::_Async_state_impl(std::_Bind_simple<void (*())()>&&)::{lam= bda ()#1} ()> >::_M_run() (this=3D0x20825008) at /usr/local/lib/gcc6/include/c++/thread:196 #9 0x201ac464 in std::execute_native_thread_routine (__p=3D0x20825008) at /usr/obj/portswork/usr/ports/lang/gcc6/work/gcc-6.2.0/libstdc++-v3/src/c++1= 1/thread.cc:83 #10 0x200affd4 in thread_start (curthread=3D<optimized out>) at /usr/src/lib/libthr/thread/thr_create.c:289 #11 0x200afa90 in _pthread_create (thread=3D0xbfbfeb78, attr=3D<optimized o= ut>, start_routine=3D<optimized out>, arg=3D<optimized out>) at /usr/src/lib/libthr/thread/thr_create.c:185 #12 0xbfbfeb5c in ?? () Backtrace stopped: previous frame identical to this frame (corrupt stack?) NOTE: kill or quit from gdb leads to gdb hanging, needing something like ki= ll -9 to deal with gdb. NOTE: "/usr/local/bin/gdb a.out a.out.core" causes gdb itself to SIGSEGV. I= 've no clue if this is an independent problem or not. It only takes the one std::async use to have the problem. So far the above = (and the earlier variants) always crash with SIGSEGV on the rpi2 when the g++6 compiler was used to build. As for the compile commands used: g++6 -g -v -std=3Dc++14 -Wpedantic -Wall -O2 -pthread -Wl,-rpath=3D/usr/local/lib/gcc6 -mcpu=3Dcortex-a7 g++6_build_crashes.cpp Omitting the -mcpu=3Dcortex-a7 still get the problem. Using -O0 instead of -O2 still gets the problem. But I'll note that my stable/11 -r304943 build and my ports builds (usr/por= ts -r421001 vintage) were/are based on using -mcpu=3Dcortex-a7 . Also the syst= em clang 3.8.0 was used to build g++6: GNU C++14 (FreeBSD Ports Collection) version 6.2.0 (armv6-portbld-freebsd11= .0) compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.8.0 (tags/RELEASE_380/final 262564), GMP version 5.1.3, MPFR version 3.1.4-p1, = MPC version 1.0.3, isl version none # uname -apKU FreeBSD rpi2 11.0-PRERELEASE FreeBSD 11.0-PRERELEASE #5 r304943M: Sun Aug 28 03:17:54 PDT 2016=20=20=20=20 markmi@FreeBSDx64:/usr/obj/clang/arm.armv6/usr/src/sys/RPI2-NODBG arm armv6 1100502 1100502 # svnlite info /usr/src | grep "Re[vl][ai:]" Relative URL: ^/stable/11 Revision: 304943 Last Changed Rev: 304943 # svnlite info /usr/ports | grep "Re[vl][ai:]" Relative URL: ^/head Revision: 421001 Last Changed Rev: 421001 # more /etc/make.conf=20 DEFAULT_VERSIONS+=3Dperl5=3D5.22 WRKDIRPREFIX=3D/usr/obj/portswork WITH_DEBUG=3D WITH_DEBUG_FILES=3D MALLOC_PRODUCTION=3D # #system clang 3.8 (gcc6 rejects -march=3Darmv7a): #CFLAGS+=3D -march=3Darmv7-a -mcpu=3Dcortex-a7 #CXXFLAGS+=3D -march=3Darmv7-a -mcpu=3Dcortex-a7 #CPPFLAGS+=3D -march=3Darmv7-a -mcpu=3Dcortex-a7 # #lang/gcc6's xgcc stage considers the above conflicting so use just: CFLAGS+=3D -mcpu=3Dcortex-a7 CXXFLAGS+=3D -mcpu=3Dcortex-a7 CPPFLAGS+=3D -mcpu=3Dcortex-a7 amd64 FreeBSD does not have this problem in my testing. Beyond amd64 FreeBSD not having the problem that armv6 has. . . I have since booted Ubuntu Mate 16.04 on the rpi2 (armv6 / cortex-a7) and installed g++-6, g++-6 (Ubuntu 6.1.1-2ubuntu12~16.04) 6.1.1 20160510 since = it was available. (So not 6.2: not a full vintage match to my FreeBSD g++6 contexts, unfortunately.) The original program that failed on FreeBSD when compiled with g++6 (v6.2) = on the same rpi2 executes just fine after being compiled on the Ubuntu Mate rp= i2 configuration with g++-6 (v6.1). So the armv6 SIGSEGV looks to not not be a generic g++6/libstdc++ problem f= or std::async use: it seems to be armv6 FreeBSD specific. (Unfortunately I've = not been able to form fully matching versions for this comparison.) I've also installed g++-6 on a ODROID-C2 (aarch64) Linux (Ubuntu 16.04.1) a= nd built the original program that I discovered the problem with. g++-6 (Ubuntu 6.1.1-2ubuntu12~16.04) 6.1.1 20160510 was the compiler. It executes just fine on the ODROID-C2 under Ubuntu Mate. (So far as I know FreeBSD does not support this type of context (yet) but it is the only aarc= h64 context I currently have access to.) --=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-212330-13>