public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54044] New: Calling captured function parameter in std::thread leads to SIGABRT
@ 2012-07-20  9:50 tasptz at gmail dot com
  2012-07-20 10:20 ` [Bug c++/54044] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: tasptz at gmail dot com @ 2012-07-20  9:50 UTC (permalink / raw)
  To: gcc-bugs

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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/54044] Calling captured function parameter in std::thread leads to SIGABRT
  2012-07-20  9:50 [Bug c++/54044] New: Calling captured function parameter in std::thread leads to SIGABRT tasptz at gmail dot com
@ 2012-07-20 10:20 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-20 10:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54044

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-20 10:19:50 UTC ---
See [thread.thread.destr]

~thread();

-1- If joinable(), calls std::terminate().


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-20 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20  9:50 [Bug c++/54044] New: Calling captured function parameter in std::thread leads to SIGABRT tasptz at gmail dot com
2012-07-20 10:20 ` [Bug c++/54044] " redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).