[LLVMbugs] [Bug 15431] New: pthread_key_create aborts program instead of returning an error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Mar 3 06:48:24 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=15431

            Bug ID: 15431
           Summary: pthread_key_create aborts program instead of returning
                    an error
           Product: libc++
           Version: 3.2
          Hardware: Macintosh
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: d.frey at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I created a small test program that checks if pthread_key_create returns with
an error when too many keys are created:

#include <stdexcept>
#include <vector>
#include <pthread.h>

struct thread_specific
{
  pthread_key_t key_;
  thread_specific()
  {
    if( pthread_key_create( &key_, NULL ) != 0 ) {
      throw std::runtime_error( "pthread_key_create() failed" );
    }
  }
};

int main()
{
  std::vector< thread_specific > v;
  while( true ) {
    v.emplace_back( thread_specific() );
  }
}

The program throws the expected exception from the source with GCC 4.7 and with
Clang 3.2 with libstdc++. However, if I use libc++, the program is aborted
which I consider an error. Here's the output from my terminal, first the two
good-cases, last the bad-case:

$g++ -std=c++11 -pthread -O3 -Wall -Wextra t.cc -o t && ./t
terminate called after throwing an instance of 'std::runtime_error'
  what():  pthread_key_create() failed
Aborted (core dumped)
$clang++ -std=c++11 -pthread -O3 -Wall -Wextra t.cc -o t && ./t
terminate called after throwing an instance of 'std::runtime_error'
  what():  pthread_key_create() failed
Aborted (core dumped)
$clang++ -std=c++11 -stdlib=libc++ -pthread -O3 -Wall -Wextra t.cc -o t && ./t
cannot create pthread key for __cxa_get_globals()
Aborted (core dumped)
$

I'm on Ubuntu 12.10 (virtualized), Clang and libc++ installed via
ppa:georgekola/clang, libc++ has package version 1.0~svn170866-1~exp1ubuntu2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130303/b22f383d/attachment.html>


More information about the llvm-bugs mailing list