Debian Bug report logs - #576485
libstdc++: std::thread completely broken

version graph

Package: libstdc++6; Maintainer for libstdc++6 is Debian GCC Maintainers <debian-gcc@lists.debian.org>; Source for libstdc++6 is src:gcc-4.9.

Reported by: Miles Bader <miles@gnu.org>

Date: Mon, 5 Apr 2010 03:48:02 UTC

Severity: normal

Found in version gcc-4.5/4.5-20100227-1

Done: Matthias Klose <doko@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#576485; Package libstdc++6. (Mon, 05 Apr 2010 03:48:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Miles Bader <miles@gnu.org>:
New Bug report received and forwarded. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. (Mon, 05 Apr 2010 03:48:05 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Miles Bader <miles@gnu.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: libstdc++: std::thread completely broken
Date: Mon, 05 Apr 2010 12:43:26 +0900
Package: libstdc++6
Version: 4.5-20100227-1
Severity: normal
File: libstdc++



The following program:

  #include <iostream>
  #include <thread>

  int g = 0;

  void f ()
  {
    g++;
  }

  int main ()
  {
    std::thread t (f);
    t.join ();
    std::cout << "after joing, g = " << g << std::endl;
    return 0;
  }


Dies with an exception:

  $ g++-4.5 --version
  g++-4.5 (Debian 4.5-20100227-1) 4.5.0 20100227 (experimental) [trunk
  revision 157109]

  $ g++-4.5 -std=c++0x -o t t.cc

  $ ./t
  terminate called after throwing an instance of 'std::system_error'
    what():
  Aborted


Thanks,

-Miles


-- System Information:
Debian Release: squeeze/sid
  APT prefers oldstable
  APT policy: (500, 'oldstable'), (500, 'unstable'), (500, 'stable'), (50, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.33-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=ja_JP.UTF-8, LC_CTYPE=ja_JP.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libstdc++6 depends on:
ii  gcc-4.5-base            4.5-20100227-1   The GNU Compiler Collection (base 
ii  libc6                   2.10.2-6         Embedded GNU C Library: Shared lib
ii  libgcc1                 1:4.5-20100227-1 GCC support library

libstdc++6 recommends no packages.

libstdc++6 suggests no packages.

-- no debconf information




Information forwarded to debian-bugs-dist@lists.debian.org, Debian GCC Maintainers <debian-gcc@lists.debian.org>:
Bug#576485; Package libstdc++6. (Mon, 05 Apr 2010 04:18:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Miles Bader <miles@gnu.org>:
Extra info received and forwarded to list. Copy sent to Debian GCC Maintainers <debian-gcc@lists.debian.org>. (Mon, 05 Apr 2010 04:18:03 GMT) Full text and rfc822 format available.

Message #10 received at 576485@bugs.debian.org (full text, mbox):

From: Miles Bader <miles@gnu.org>
To: 576485@bugs.debian.org
Subject: Re: Bug#576485: Acknowledgement (libstdc++: std::thread completely broken)
Date: Mon, 05 Apr 2010 13:06:23 +0900
BTW, one thing I noticed is that the "error code" field in the
std::system_error exception which is raised, seems to be set to EPERM
("Operation not permitted"), but this code is not apparently caused by a
system call (determined by stracing the process).

For instance, changing the test case to this:

  #include <cerrno>
  #include <iostream>
  #include <thread>

  int g = 0;

  void f ()
  {
    g++;
  }

  int main ()
  {
    std::cerr << "before thread creation..." << std::endl;
    try {
      errno = 0;
      std::thread t (f);
      std::cerr << "after thread creation..." << std::endl;
      t.join ();
    } catch (const std::system_error &e) {
      std::cerr << "caught std::system_error, what = \""
		<< e.what ()
		<< "\", code = " << e.code().message ()
		<< std::endl;
    }
    std::cout << "after joing, g = " << g << std::endl;
    return 0;
  }

Results in this:

   $ g++-4.5 -std=c++0x -o t t.cc
   $ ./t
   before thread creation...
   caught std::system_error, what = "", code = Operation not permitted
   after joing, g = 0

strace shows this:

   $ strace ./t 2>&1 | tail -20
   mprotect(0x7f2036a9c000, 16384, PROT_READ) = 0
   mprotect(0x7f2036f3c000, 4096, PROT_READ) = 0
   mprotect(0x7f2037229000, 32768, PROT_READ) = 0
   mprotect(0x7f2037464000, 4096, PROT_READ) = 0
   munmap(0x7f203744b000, 90011)           = 0
   write(2, "before thread creation...", 25before thread creation...) = 25
   write(2, "\n", 1
   )                       = 1
   brk(0)                                  = 0x18b2000
   brk(0x18d3000)                          = 0x18d3000
   write(2, "caught std::system_error, what ="..., 34caught std::system_error, what = ") = 34
   write(2, "\", code = ", 10", code = )             = 10
   write(2, "Operation not permitted", 23Operation not permitted) = 23
   write(2, "\n", 1
   )                       = 1
   fstat(1, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
   mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2037460000
   write(1, "after joing, g = 0\n", 19after joing, g = 0
   )    = 19
   exit_group(0)                           = ?


Thanks,

-Miles

-- 
Cabbage, n. A familiar kitchen-garden vegetable about as large and wise as a
man's head.




Reply sent to Matthias Klose <doko@debian.org>:
You have taken responsibility. (Tue, 06 Apr 2010 02:18:06 GMT) Full text and rfc822 format available.

Notification sent to Miles Bader <miles@gnu.org>:
Bug acknowledged by developer. (Tue, 06 Apr 2010 02:18:06 GMT) Full text and rfc822 format available.

Message #15 received at 576485-done@bugs.debian.org (full text, mbox):

From: Matthias Klose <doko@debian.org>
To: Miles Bader <miles@gnu.org>, 576485-done@bugs.debian.org
Subject: Re: Bug#576485: libstdc++: std::thread completely broken
Date: Tue, 06 Apr 2010 03:42:17 +0200
On 05.04.2010 05:43, Miles Bader wrote:
> Dies with an exception:
>
>    $ g++-4.5 --version
>    g++-4.5 (Debian 4.5-20100227-1) 4.5.0 20100227 (experimental) [trunk
>    revision 157109]
>
>    $ g++-4.5 -std=c++0x -o t t.cc
>
>    $ ./t
>    terminate called after throwing an instance of 'std::system_error'
>      what():
>    Aborted

need to build with -pthread.




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 04 May 2010 07:36:40 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Mon Apr 21 03:18:48 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.