mailing list of musl libc
 help / color / mirror / code / Atom feed
* value of thread-specific data immediately after initialization
@ 2018-09-13 20:39 Benjamin Peterson
  2018-09-17 20:54 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Peterson @ 2018-09-13 20:39 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-18  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13 20:39 value of thread-specific data immediately after initialization Benjamin Peterson
2018-09-17 20:54 ` Rich Felker
2018-09-18  3:18   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).