threads/144558: Repeated calls to __rpc_createerr allocates multiple thread-specific data slots

Sam Robb samrobb at averesystems.com
Mon Mar 8 19:00:20 UTC 2010


The following reply was made to PR threads/144558; it has been noted by GNATS.

From: Sam Robb <samrobb at averesystems.com>
To: bug-followup at FreeBSD.org,
 Sam Robb <samrobb at averesystems.com>
Cc:  
Subject: Re: threads/144558: Repeated calls to __rpc_createerr allocates multiple thread-specific data slots
Date: Mon, 8 Mar 2010 13:36:16 -0500

 Example program that shows repeated allocation of thread-specific data =
 slots caused by calling clnt_pcreateerror() from a thread.
 
 #include <netinet/in.h>
 #include <rpc/rpc.h>
 #include <rpc/clnt.h>
 #include <rpcsvc/rex.h>
 #include <stdio.h>
 #include <assert.h>
 #include <stdlib.h>
 
 void *
 rce_test(void * arg)
 {
 	struct sockaddr_in addr;
 	int i =3D 0;
 	pthread_key_t thr_key_start =3D -1;
 	pthread_key_t thr_key_end =3D -1;
 	int * pdata =3D malloc(sizeof(int));
 
 	pthread_key_create(&thr_key_start, pdata);
 	printf("thr_key_start =3D %d\n", thr_key_start);
 
 	for (i =3D 0; i <=3D 25 ; i++) {
 		CLIENT * client =3D NULL;
 		char buf[256];
 		pthread_key_t thr_key_intermediate =3D -1;
 
 		sprintf(buf, "Call #%d", i);
 		client =3D clnt_create("127.0.0.2", REXPROG, REXVERS, =
 "udp");
 		clnt_pcreateerror(buf);
 
 		pthread_key_create(&thr_key_intermediate, pdata);
 		printf("thr_key_intermediate =3D %d\n", =
 thr_key_intermediate);
 
 		if (client) {
 			clnt_destroy(client);
 		}
 	}
 
 	pthread_key_create(&thr_key_end, pdata);
 	printf("thr_key_end =3D %d\n", thr_key_end);
 
 	return pdata;
 }
 
 int main(int argc, char** argv)
 {
         pthread_t       thread;
         void            *result;
         pthread_attr_t  attr =3D 0;
         int             res =3D 0;
 
         res =3D pthread_create(&thread, &attr, rce_test, NULL);
         assert(res =3D=3D 0);
 
         res =3D pthread_join(thread, &result);
         assert(res =3D=3D 0);
 
 	return 0;
 }
 


More information about the freebsd-threads mailing list