Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1536871178.1074978.1507360824.56778F86@webmail.messagingengine.com>
Date: Thu, 13 Sep 2018 13:39:38 -0700
From: Benjamin Peterson <benjamin@...hon.org>
To: musl@...ts.openwall.com
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_delete(k);
	pthread_key_create(&k, NULL);
	printf("%p\n", pthread_getspecific(k));
	pthread_key_delete(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 
0
0x7fff2ba3d004

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.