Date: Mon, 8 Mar 2010 17:51:39 GMT From: Sam Robb <samrobb@averesystems.com> To: freebsd-gnats-submit@FreeBSD.org Subject: threads/144558: Repeated calls to __rpc_createerr allocates multiple thread-specific data slots Message-ID: <201003081751.o28HpdCg016822@www.freebsd.org> Resent-Message-ID: <201003081800.o28I0Hh7030050@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 144558 >Category: threads >Synopsis: Repeated calls to __rpc_createerr allocates multiple thread-specific data slots >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 08 18:00:16 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Sam Robb >Release: 7.1 >Organization: Avere Systems >Environment: FreeBSD build1.arriad.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 08:58:24 UTC 2009 root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: On the first call to __rpc_createerr() in a thread, the function attempts to allocate a thread-specific slot to hold the rpc error data. Subsequent calls from the same thread continue to allocate new thread-specific slots without freeing the first, so that repeated calls eventually result in all available thread-specific data slots being allocated. >How-To-Repeat: >Fix: Patch attached Patch attached with submission follows: --- a/src/lib/libc/rpc/mt_misc.c +++ b/src/lib/libc/rpc/mt_misc.c @@ -89,15 +89,16 @@ struct rpc_createerr rpc_createerr; struct rpc_createerr * __rpc_createerr() { - static thread_key_t rce_key = 0; + static thread_key_t rce_key = -1; struct rpc_createerr *rce_addr = 0; if (thr_main()) return (&rpc_createerr); if ((rce_addr = - (struct rpc_createerr *)thr_getspecific(rce_key)) != 0) { + (struct rpc_createerr *)thr_getspecific(rce_key)) == 0) { mutex_lock(&tsd_lock); - if (thr_keycreate(&rce_key, free) != 0) { + if ((rce_key == -1) && + (thr_keycreate(&rce_key, free) != 0)) { mutex_unlock(&tsd_lock); return (&rpc_createerr); } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003081751.o28HpdCg016822>