Bug 508475 - Program crashes constructing std::thread
Program crashes constructing std::thread
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
11
i686 Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-27 11:51 EDT by Pedro Lamarão
Modified: 2009-07-08 04:51 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-07-08 04:51:35 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Pedro Lamarão 2009-06-27 11:51:34 EDT
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 14:37:40 EDT
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 04:51:35 EDT
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.