Prosty test, który działa niepoprawnie pod ubuntu.
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
#include <future> #include <iostream> int foo() { sleep( 5 ); return 42; } int main() { std::future<int> result = std::async(std::launch::async, foo ); std::cout << result.get() << std::endl; std::cin.get(); return 0; }
Wykonanie kończy się przez core dump. Pod gdb na razie widać tyle:
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2 (gdb) start Temporary breakpoint 1 at 0x41baad Starting program: /home/makhzi/Pulpit/workspace/@szkolenia/async-test/async-test Temporary breakpoint 1, 0x000000000041baad in main () (gdb) s Single stepping until exit from function main, which has no line number information. terminate called after throwing an instance of 'std::system_error' what(): Program received signal SIGABRT, Aborted. 0x00007ffff72d9d05 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu. in ../nptl/sysdeps/unix/sysv/linux/raise.c (gdb) info stack #0 0x00007ffff72d9d05 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007ffff72ddab6 in abort () at abort.c:92 #2 0x00007ffff7b916dd in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007ffff7b8f926 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007ffff7b8f953 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007ffff7b8fa5e in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007ffff7b3a77a in std::__throw_system_error(int) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #7 0x000000000041c6d1 in void std::call_once<std::_Mem_fn<void (std::__future_base::_State::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()()>&, bool&)>, std::__future_base::_State* 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&, std::_Mem_fn<void (std::__future_base::_State::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()()>&, bool&)>, std::__future_base::_State* const&&, std::reference_wrapper<std::function<std::unique_ptr<std::__futu---Type <return> to continue, or q <return> to quit---info stack re_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()()> >&&, std::reference_wrapper<bool>&&) () #8 0x000000000041c16e in std::__future_base::_State::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()()>, bool) () #9 0x0000000000421fc2 in std::__future_base::_Deferred_state<int>::_M_run_deferred() () #10 0x000000000041c006 in std::__future_base::_State::wait() () #11 0x000000000041d20f in std::__basic_future<int>::_M_get_result() () #12 0x000000000041c8dc in std::future<int>::get() () #13 0x000000000041bacf in main ()