Bug 508475 - Program crashes constructing std::thread
Summary: Program crashes constructing std::thread
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 11
Hardware: i686
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-06-27 15:51 UTC by Pedro Lamarão
Modified: 2009-07-08 08:51 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-07-08 08:51:35 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Source file which demonstrates the problem (244 bytes, text/plain)
2009-06-27 15:51 UTC, Pedro Lamarão
no flags Details

Description Pedro Lamarão 2009-06-27 15:51:34 UTC
Created attachment 349662 [details]
Source file which demonstrates the problem

Description of problem:
Program crashes with SIGSEGV when constructing a std::thread.

Version-Release number of selected component (if applicable):
gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC) 

How reproducible:
Always.

Steps to Reproduce:
1. Compile the attached source file with g++ -std=c++0x
2. Run the program.
3.
  
Actual results:
Program crashes.

Expected results:
Program runs.

Additional info:
(gdb) bt full
#0  _dl_fixup (l=<value optimized out>, reloc_arg=<value optimized out>) at dl-runtime.c:139
        reloc = <value optimized out>
        sym = 0x0
        result = 0x0
        value = 0
        __PRETTY_FUNCTION__ = "_dl_fixup"
#1  0x005bf8b0 in _dl_runtime_resolve () at ../sysdeps/i386/dl-trampoline.S:37
No locals.
#2  0x07d3a9f1 in __gthread_create (__args=<value optimized out>, __func=<value optimized out>, __threadid=<value optimized out>) at /usr/src/debug/gcc-4.4.0-20090506/obj-i586-redhat-linux/i586-redhat-linux/libstdc++-v3/include/i586-redhat-linux/bits/gthr-default.h:679
No locals.
#3  std::thread::_M_start_thread (__args=<value optimized out>, __func=<value optimized out>, __threadid=<value optimized out>) at ../../../../libstdc++-v3/src/thread.cc:88
        __e = <value optimized out>
#4  0x08048a57 in std::thread::thread<Foo> (this=0xbffff348, __f={<No data fields>}) at /usr/lib/gcc/i586-redhat-linux/4.4.0/../../../../include/c++/4.4.0/thread:129
No locals.
#5  0x080488e4 in main (argc=1, argv=0xbffff404) at sandbox.cpp:25
        f = {<No data fields>}

Comment 1 Pedro Lamarão 2009-06-29 18:37:40 UTC
This bug seems to occur only when the -pthread argument to GCC is missing.
This argument is, of course, required to compile programs using pthreads.

I suppose that leaving the argument out yields "undefined behaviour".

Comment 2 Jakub Jelinek 2009-07-08 08:51:35 UTC
Obviously if you use std::thread and don't link with -lpthread, it is a developer error.  We certainly don't want to link libstdc++ against -lpthread unconditionally, just because somebody might want to use std::thread.


Note You need to log in before you can comment on or make changes to this bug.