Package: glibc-doc-reference Version: 2.7-1 Severity: normal I've attached the source to a program that displays this behaviour.
I compiled it with gcc -pthread -D_REENTRANT -o tls_test tls_test.c Either the documentation is wrong or there's a problem with glibc. The tsd dectructor function isn't being called. There's a second related problem in that the unfortunate softare developer may sometimes be forced to choose between leaking a tsd key or any number (including 0) of tsd data items. I guess if the destructor function isn't called then that simplifies this second choice. -- System Information: Debian Release: 5.0.2 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.26-2-amd64 (SMP w/2 CPU cores) Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash -- no debconf information
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> void cleanup_fn(void * p) { char * msg = (char *)p; printf("Cleaning up %s.\n", msg); free(msg); } int main(int argc, char *argv[]) { pthread_key_t key; int ret = pthread_key_create(& key, cleanup_fn); if(ret) { printf("pthread_key_create() failed.\n"); return 1; } char * msg = strdup("data"); if(!msg) { printf("strdup(\"data\") failed.\n"); return 1; } ret = pthread_setspecific(key, (void *)msg); if(ret) { printf("pthread_setspecific() failed.\n"); free(msg); return 1; } return 0; }