This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54044] New: Calling captured function parameter in std::thread leads to SIGABRT
- From: "tasptz at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jul 2012 09:49:50 +0000
- Subject: [Bug c++/54044] New: Calling captured function parameter in std::thread leads to SIGABRT
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54044
Bug #: 54044
Summary: Calling captured function parameter in std::thread
leads to SIGABRT
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tasptz@gmail.com
Created attachment 27843
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27843
CMake and source code file.
$ g++ --version
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 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.
Ubuntu 12.04 LTS 64bit
#include <functional>
#include <thread>
void b(std::function<void ()> a)
{
std::thread t([a]()
{
a();
});
}
void x()
{
}
int main()
{
b(x);
std::this_thread::sleep_for(std::chrono::seconds(10));
return 0;
}
$ gdb main
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04
Copyright (C) 2012 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-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/tom/report/build/main...done.
(gdb) r
Starting program: /home/tom/report/build/main
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff6fef700 (LWP 27634)]
terminate called without an active exception
[Thread 0x7ffff6fef700 (LWP 27634) exited]
Program received signal SIGABRT, Aborted.
0x00007ffff7320445 in __GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff7320445 in __GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff7323bab in __GI_abort () at abort.c:91
#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 0x00000000004043a1 in std::thread::~thread (this=0x7fffffffe0d0,
__in_chrg=<optimized out>) at /usr/include/c++/4.6/thread:143
#6 0x0000000000403352 in b(std::function<void ()>) (a=...) at
/home/tom/report/src/main.cpp:9
#7 0x00000000004033e1 in main () at /home/tom/report/src/main.cpp:19
(gdb)