threads/144558: Repeated calls to __rpc_createerr allocates
multiple thread-specific data slots
Sam Robb
samrobb at averesystems.com
Mon Mar 8 18:00:20 UTC 2010
>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 at 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:
More information about the freebsd-threads
mailing list