Cause Fatal error when invalid pthread_id is detected.

This is a patch testing whether we can use abort() instead of
returning ESRCH for invalid pthread ids. It is an intermediate
step to remove g_thread_list/g_thread_list_lock.

Bug: 19636317
Change-Id: Idd8e4a346c7ce91e1be0c2ebcb78ce51c0d0a31d
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp
index 1967ccf..afafad8 100644
--- a/libc/bionic/pthread_internal.cpp
+++ b/libc/bionic/pthread_internal.cpp
@@ -81,12 +81,16 @@
 
 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;
 }