Merge "Revert "Cause Fatal error when invalid pthread_id is detected.""
This commit is contained in:
commit
8f3eb5a4e5
2 changed files with 11 additions and 47 deletions
|
@ -81,16 +81,12 @@ void __pthread_internal_remove_and_free(pthread_internal_t* thread) {
|
|||
|
||||
pthread_internal_t* __pthread_internal_find(pthread_t thread_id) {
|
||||
pthread_internal_t* thread = reinterpret_cast<pthread_internal_t*>(thread_id);
|
||||
{
|
||||
ScopedPthreadMutexLocker locker(&g_thread_list_lock);
|
||||
ScopedPthreadMutexLocker locker(&g_thread_list_lock);
|
||||
|
||||
for (pthread_internal_t* t = g_thread_list; t != NULL; t = t->next) {
|
||||
if (t == thread) {
|
||||
return thread;
|
||||
}
|
||||
for (pthread_internal_t* t = g_thread_list; t != NULL; t = t->next) {
|
||||
if (t == thread) {
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
// TODO: Remove g_thread_list/g_thread_list_lock when the fatal error below doesn't happen.
|
||||
__libc_fatal("No such thread: %p", thread);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -400,17 +400,12 @@ TEST(pthread, pthread_setname_np__other) {
|
|||
ASSERT_EQ(0, pthread_setname_np(t1, "short 2"));
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_setname_np__no_such_thread) {
|
||||
TEST(pthread, pthread_setname_np__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
// Call pthread_setname_np after thread has already exited.
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_setname_np(dead_thread, "short 3"), testing::KilledBySignal(SIGABRT),
|
||||
"No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ENOENT, pthread_setname_np(dead_thread, "short 3"));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(pthread, pthread_kill__0) {
|
||||
|
@ -436,15 +431,11 @@ TEST(pthread, pthread_kill__in_signal_handler) {
|
|||
ASSERT_EQ(0, pthread_kill(pthread_self(), SIGALRM));
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_detach__no_such_thread) {
|
||||
TEST(pthread, pthread_detach__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_detach(dead_thread), testing::KilledBySignal(SIGABRT), "No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_detach(dead_thread));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(pthread, pthread_detach_no_leak) {
|
||||
|
@ -495,67 +486,44 @@ TEST(pthread, pthread_getcpuclockid__clock_gettime) {
|
|||
ASSERT_EQ(0, clock_gettime(c, &ts));
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_getcpuclockid__no_such_thread) {
|
||||
TEST(pthread, pthread_getcpuclockid__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
clockid_t c;
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_getcpuclockid(dead_thread, &c), testing::KilledBySignal(SIGABRT),
|
||||
"No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_getcpuclockid(dead_thread, &c));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_getschedparam__no_such_thread) {
|
||||
TEST(pthread, pthread_getschedparam__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
int policy;
|
||||
sched_param param;
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_getschedparam(dead_thread, &policy, ¶m), testing::KilledBySignal(SIGABRT),
|
||||
"No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_getschedparam(dead_thread, &policy, ¶m));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_setschedparam__no_such_thread) {
|
||||
TEST(pthread, pthread_setschedparam__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
int policy = 0;
|
||||
sched_param param;
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_setschedparam(dead_thread, policy, ¶m), testing::KilledBySignal(SIGABRT),
|
||||
"No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_setschedparam(dead_thread, policy, ¶m));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_join__no_such_thread) {
|
||||
TEST(pthread, pthread_join__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_join(dead_thread, NULL), testing::KilledBySignal(SIGABRT), "No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_join(dead_thread, NULL));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(pthread_DeathTest, pthread_kill__no_such_thread) {
|
||||
TEST(pthread, pthread_kill__no_such_thread) {
|
||||
pthread_t dead_thread;
|
||||
MakeDeadThread(dead_thread);
|
||||
|
||||
#if defined(__BIONIC__)
|
||||
ASSERT_EXIT(pthread_kill(dead_thread, 0), testing::KilledBySignal(SIGABRT), "No such thread");
|
||||
#else
|
||||
ASSERT_EQ(ESRCH, pthread_kill(dead_thread, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(pthread, pthread_join__multijoin) {
|
||||
|
|
Loading…
Reference in a new issue