amd64/164828: pthread_create/join memory leak

Florian Wilkemeyer fw at f-ws.de
Mon Feb 6 17:10:10 UTC 2012


>Number:         164828
>Category:       amd64
>Synopsis:       pthread_create/join memory leak
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-amd64
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 06 17:10:09 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Florian Wilkemeyer
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD 9test 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
I recently noticed that pthread_create/join  leaks memory
when you're going to create & destroy masses of threads.



Test code: (compiled with gcc -o test test.c -lphtread) 

#include <pthread.h>


void *thrProc(void *arg){
        pthread_exit(NULL);
}


int main(){
        pthread_t thr;
        
        while(1){
                thr = NULL;
                pthread_create(&thr, NULL, thrProc, NULL);
                pthread_join(thr, NULL);
        }

        return 0;
}



The same code runs on 8.2 without problems:

FreeBSD wilkemeyer-laptop 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #0: Thu Jul 21 20:11:49 CEST 2011     root at wilkemeyer-laptop:/usr/obj/usr/src/sys/WILKEMEYER_LAPTOP  amd64





>How-To-Repeat:

#include <pthread.h>


void *thrProc(void *arg){
        pthread_exit(NULL);
}


int main(){
        pthread_t thr;
        
        while(1){
                thr = NULL;
                pthread_create(&thr, NULL, thrProc, NULL);
                pthread_join(thr, NULL);
        }

        return 0;
}

// compile with
// gcc -o test test.c -lphtread
//
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-amd64 mailing list