diff options
| author | Rich Felker <dalias@aerifal.cx> | 2019-09-06 15:52:00 -0400 | 
|---|---|---|
| committer | Rich Felker <dalias@aerifal.cx> | 2019-09-06 15:54:32 -0400 | 
| commit | dd0a23dd9e157624347fdcc9dca452675b93da70 (patch) | |
| tree | ca3d079010992786a564f9d11904722682f97dba /src | |
| parent | a882841baf42e6a8b74cc33a239b84a9a79493db (diff) | |
| download | musl-dd0a23dd9e157624347fdcc9dca452675b93da70.tar.gz | |
fix unsynchronized decrement of thread count on pthread_create error
commit 8f11e6127fe93093f81a52b15bb1537edc3fc8af wrongly documented
that all changes to libc.threads_minus_1 were guarded by the thread
list lock, but the decrement for failed SYS_clone took place after the
thread list lock was released.
Diffstat (limited to 'src')
| -rw-r--r-- | src/thread/pthread_create.c | 3 | 
1 files changed, 2 insertions, 1 deletions
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index ebf61ded..edaf9a6e 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -356,13 +356,14 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att  		new->prev = self;  		new->next->prev = new;  		new->prev->next = new; +	} else { +		libc.threads_minus_1--;  	}  	__tl_unlock();  	__restore_sigs(&set);  	__release_ptc();  	if (ret < 0) { -		libc.threads_minus_1--;  		if (map) __munmap(map, size);  		return EAGAIN;  	}  | 
