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: [email protected]
Reporter: [email protected]
CC: [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs