Gibt der Coredump irgendwelche Informationen preis?
Hier erstmal der Stack
Program received signal SIGABRT, Aborted.
0x00007ffff753a425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) where
#0 0x00007ffff753a425 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff753db8b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff7b9169d in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff7b8f846 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff7b8f873 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff7b8f96e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff7b3cc8e in std::__throw_system_error(int) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x000000000040277c in std::call_once<void (std::__future_base::_State_base::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>&, bool&), std::__future_base::_State_base* const, std::reference_wrapper<std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()> >, std::reference_wrapper<bool> >(std::once_flag&, void (std::__future_base::_State_base::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>&, bool&), std::__future_base::_State_base* const&&, std::reference_wrapper<std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()> >&&, std::reference_wrapper<bool>&&) (__once=..., __f=
@0x7fffffffdf40: (void (std::__future_base::_State_base::*)(std::__future_base::_State_base * const, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter>()> &, bool &)) 0x4022da <std::__future_base::_State_base::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>&, bool&)>) at /usr/include/c++/4.6/mutex:819
#8 0x0000000000402291 in std::__future_base::_State_base::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) (this=0x611030, __res=..., __ignore_failure=true)
at /usr/include/c++/4.6/future:337
#9 0x0000000000408187 in std::__future_base::_Deferred_state<int>::_M_run_deferred (this=0x611030)
at /usr/include/c++/4.6/future:1320
#10 0x000000000040213c in std::__future_base::_State_base::wait (this=0x611030) at /usr/include/c++/4.6/future:305
#11 0x00000000004037b5 in std::__basic_future<int>::_M_get_result (this=0x7fffffffe1a0) at /usr/include/c++/4.6/future:548
#12 0x0000000000402b86 in std::future<int>::get (this=0x7fffffffe1a0) at /usr/include/c++/4.6/future:627
#13 0x0000000000401ba2 in main () at async.cpp:45
Falls Du keinen core bekommst, schau mal auf ulimit -a.
Du solltest dann noch sagen, wie man das ändert, falls dort bei "core size" eine 0 angegeben ist. ☺ (Antwort: Es geht z.B. mit 'ulimit -c 1000000'.)
Dann mal mit einem try-catch:
$ ./a.out
starting func1() in background and func2() in foreground:
++++++++++
Caught system_error with code "generic:-1" meaning "Unknown error -1".
result of func1()+func2(): 0
Also auch nicht sehr hilfreich.
Update: Aber wenn man etwas sucht, findet man die Lösung (erster Treffer der Suche. *g*): http://www.cplusplus.com/forum/beginner/115878/
$ g++ -std=c++11 -pthread async.cpp
$ ./a.out
starting func1() in background and func2() in foreground:
++++++++++..........
result of func1()+func2(): 89
Das "-pthread" ist also wichtig, damit überhaupt irgendwas mit mehr als einem Thread funktioniert.
Gruß Dee