Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 13 Sep 2018 13:39:38 -0700
From: Benjamin Peterson <>
Subject: value of thread-specific data immediately after initialization

POSIX says that after the creation of a thread-specific key, its associated value should be NULL in all threads. musl may not uphold this requirement if a particular key is deleted and later resued.

Here's an example of the bug:

#include <pthread.h>
#include <stdio.h>

int main() {
	pthread_key_t k;
	pthread_key_create(&k, NULL);
	printf("%p\n", pthread_getspecific(k));
	pthread_setspecific(k, &k);
	pthread_key_create(&k, NULL);
	printf("%p\n", pthread_getspecific(k));
	return 0;

Per POSIX, I would expect this testcase to output two NULLs. However, musl prints the address of the old data even after the second initialization:

$ musl-gcc -o test test.c
$ ./test 

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.