Merge "Do not clear tids on detached threads."
This commit is contained in:
		@@ -36,6 +36,7 @@
 | 
			
		||||
 | 
			
		||||
extern "C" void _exit_with_stack_teardown(void*, size_t, int);
 | 
			
		||||
extern "C" void __exit(int);
 | 
			
		||||
extern "C" int __set_tid_address(int*);
 | 
			
		||||
 | 
			
		||||
/* CAVEAT: our implementation of pthread_cleanup_push/pop doesn't support C++ exceptions
 | 
			
		||||
 *         and thread cancelation
 | 
			
		||||
@@ -94,6 +95,9 @@ void pthread_exit(void* return_value) {
 | 
			
		||||
  pthread_mutex_lock(&gThreadListLock);
 | 
			
		||||
  if ((thread->attr.flags & PTHREAD_ATTR_FLAG_DETACHED) != 0) {
 | 
			
		||||
    // The thread is detached, so we can destroy the pthread_internal_t.
 | 
			
		||||
    // First make sure that the thread does not try to clear the tid since
 | 
			
		||||
    // it points into memory that will be freed.
 | 
			
		||||
    __set_tid_address(NULL);
 | 
			
		||||
    _pthread_internal_remove_locked(thread);
 | 
			
		||||
  } else {
 | 
			
		||||
    // Make sure that the pthread_internal_t doesn't have stale pointers to a stack that
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user