public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* std::thread segfault
@ 2009-04-14 21:24 Matthew Lai
  2009-04-17 11:45 ` Timothy Brownawell
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Lai @ 2009-04-14 21:24 UTC (permalink / raw)
  To: gcc-help

I'm using my 4.4.0 SVN checked out a few days ago, and I tried to use 
C++0x's std::thread, but it kept segfaulting on me.

This is on 64-bit Linux, x86-64 (Ubuntu 8.10).

-------------------------------------------------
#include <thread>

void t() {
}

int main() {
    std::thread t1(&t);

    t1.join();
}
-------------------------------------------------

-------------------------------------------------
cyberfish@cyberfish-desktop:/tmp$ g++-4.4 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --prefix=/opt/gcc 
--with-system-zlib --without-included-gettext --disable-nls 
--enable-libstdcxx-debug --enable-checking=release --build=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.0 20090407 (prerelease) (GCC)
cyberfish@cyberfish-desktop:/tmp$ g++-4.4 -g -std=gnu++0x a.cpp
cyberfish@cyberfish-desktop:/tmp$ gdb a.out
GNU gdb 6.8-debian
Copyright (C) 2008 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"...
(gdb) r
Starting program: /tmp/a.out

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007fab24c6ffa7 in std::thread::_M_start_thread 
(this=0x7fff2d0db420,
    __b=DWARF-2 expression error: DW_OP_reg operations must be used 
either alone or in conjuction with DW_OP_piece.
)
    at 
/home/cyberfish/gcc_svn/gcc/build/x86_64-linux-gnu/libstdc++-v3/include/x86_64-linux-gnu/bits/gthr-default.h:682
#2  0x0000000000400dce in thread<void (*)()> (this=0x7fff2d0db420,
    __f=0x400bbc <t()>)
    at 
/opt/gcc/lib/gcc/x86_64-linux-gnu/4.4.0/../../../../include/c++/4.4.0/thread:134
#3  0x0000000000400bde in main () at a.cpp:7
(gdb) l
1    #include <thread>
2   
3    void t() {
4    }
5   
6    int main() {
7        std::thread t1(&t);
8   
9        t1.join();
10    }
(gdb)
-------------------------------------------------

Thanks
Matthew Lai

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

* Re: std::thread segfault
  2009-04-14 21:24 std::thread segfault Matthew Lai
@ 2009-04-17 11:45 ` Timothy Brownawell
  2009-04-17 19:17   ` Matthew Lai
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy Brownawell @ 2009-04-17 11:45 UTC (permalink / raw)
  To: Matthew Lai; +Cc: gcc-help

On Tue, 2009-04-14 at 14:24 -0700, Matthew Lai wrote:
> I'm using my 4.4.0 SVN checked out a few days ago, and I tried to use 
> C++0x's std::thread, but it kept segfaulting on me.

It did this to me too, some time with google turned up (besides this
message)
   http://gcc.gnu.org/ml/libstdc++/2009-02/txt00002.txt
which makes it looks like "-pthread" is needed. And giving that option
does indeed seem to make it work here.

> This is on 64-bit Linux, x86-64 (Ubuntu 8.10).
> 
> -------------------------------------------------
> #include <thread>
> 
> void t() {
> }
> 
> int main() {
>     std::thread t1(&t);
> 
>     t1.join();
> }
> -------------------------------------------------


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

* Re: std::thread segfault
  2009-04-17 11:45 ` Timothy Brownawell
@ 2009-04-17 19:17   ` Matthew Lai
  0 siblings, 0 replies; 3+ messages in thread
From: Matthew Lai @ 2009-04-17 19:17 UTC (permalink / raw)
  To: Timothy Brownawell; +Cc: gcc-help

Thanks!

That works for me, too.

Is it intended that -pthread is required for std::thread? Even if it 
is... I don't think "Segmentation fault" is that helpful an error message.

Matthew Lai


Timothy Brownawell wrote:
> On Tue, 2009-04-14 at 14:24 -0700, Matthew Lai wrote:
>   
>> I'm using my 4.4.0 SVN checked out a few days ago, and I tried to use 
>> C++0x's std::thread, but it kept segfaulting on me.
>>     
>
> It did this to me too, some time with google turned up (besides this
> message)
>    http://gcc.gnu.org/ml/libstdc++/2009-02/txt00002.txt
> which makes it looks like "-pthread" is needed. And giving that option
> does indeed seem to make it work here.
>
>   
>> This is on 64-bit Linux, x86-64 (Ubuntu 8.10).
>>
>> -------------------------------------------------
>> #include <thread>
>>
>> void t() {
>> }
>>
>> int main() {
>>     std::thread t1(&t);
>>
>>     t1.join();
>> }
>> -------------------------------------------------
>>     
>
>   

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

end of thread, other threads:[~2009-04-17 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 21:24 std::thread segfault Matthew Lai
2009-04-17 11:45 ` Timothy Brownawell
2009-04-17 19:17   ` Matthew Lai

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).