From owner-freebsd-threads@FreeBSD.ORG Mon Mar 8 18:00:20 2010 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27DDA1065674 for ; Mon, 8 Mar 2010 18:00:20 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 04A8B8FC15 for ; Mon, 8 Mar 2010 18:00:20 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o28I0HtY030051 for ; Mon, 8 Mar 2010 18:00:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o28I0Hh7030050; Mon, 8 Mar 2010 18:00:17 GMT (envelope-from gnats) Resent-Date: Mon, 8 Mar 2010 18:00:17 GMT Resent-Message-Id: <201003081800.o28I0Hh7030050@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Sam Robb Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA201106566B for ; Mon, 8 Mar 2010 17:51:39 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id B8A4B8FC1B for ; Mon, 8 Mar 2010 17:51:39 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o28Hpd3H016823 for ; Mon, 8 Mar 2010 17:51:39 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o28HpdCg016822; Mon, 8 Mar 2010 17:51:39 GMT (envelope-from nobody) Message-Id: <201003081751.o28HpdCg016822@www.freebsd.org> Date: Mon, 8 Mar 2010 17:51:39 GMT From: Sam Robb To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/144558: Repeated calls to __rpc_createerr allocates multiple thread-specific data slots X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2010 18:00:20 -0000 >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: