From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 7900D383E829 for ; Tue, 2 Jun 2020 03:41:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7900D383E829 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-qpyIQHxGMfSqoIfST8FkNw-1; Mon, 01 Jun 2020 23:41:14 -0400 X-MC-Unique: qpyIQHxGMfSqoIfST8FkNw-1 Received: by mail-qk1-f200.google.com with SMTP id d145so10142614qkg.22 for ; Mon, 01 Jun 2020 20:41:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=pgR/TiFXKxj8E7K1ukU6JEPnWwJEOqTwj0xTmz0mBNY=; b=EXjgJP6S1dP2eMGD7qxyx4O4I66zIoMncvTW26T/xZ/pIXwE6X3JwslntRmg2Hzn0Q bG6W5rKVLOGZmmcSXfkIR/n45lfAaEOucsyusuk495/WQrJoBA6uZoz4MgB1rZyIJLeB FWt8e+RT04R1DcyIrdM4kl9OEkCZOVYeaB8eHULYbKmr/5b9FdqFexGS53keXtczXIUW p2WheLzlavTUd0mwTPAXnWAH00PccgRovDOrbbTX+VQrjOIv+i/iAedDBMBX9RL5/GyA sakwNnkssF+7BXZPvEKfWPx6nC8ijwgkOl3FtC1n+96fvg4NDfrFnMghtH9ov1z+VTGJ DU/g== X-Gm-Message-State: AOAM533eI95wPk+DZ5GpJHc1rgE7pnHQq10PV+CwmE3woq+64ssTgFBW EPiJz3pTU6Be8ASjtBSGkhXX0UZTZ9mJMwOa8XbzcfQztTcJ/Aves6WsSpNzXolzhUqdzPXOcMI IyOOJx97xHSmrlvooOI/L X-Received: by 2002:ae9:e8cc:: with SMTP id a195mr21917462qkg.408.1591069273898; Mon, 01 Jun 2020 20:41:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7T11eUB75OhivG248AGq0x+Lmh4UJlO9b1F++1HUbWy4mZgcM1Ac0O2unL6dvqyoSwpfPCw== X-Received: by 2002:ae9:e8cc:: with SMTP id a195mr21917455qkg.408.1591069273664; Mon, 01 Jun 2020 20:41:13 -0700 (PDT) Received: from [192.168.1.4] (198-84-170-103.cpe.teksavvy.com. [198.84.170.103]) by smtp.gmail.com with ESMTPSA id m10sm1384507qtg.94.2020.06.01.20.41.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 20:41:13 -0700 (PDT) Subject: Re: [PATCH 15/19] nptl: Destroy the default thread attribute as part of freeres To: Florian Weimer , libc-alpha@sourceware.org References: From: Carlos O'Donell Organization: Red Hat Message-ID: <7d5f7682-aec5-1c1d-f199-5ff3ac079418@redhat.com> Date: Mon, 1 Jun 2020 23:41:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 03:41:17 -0000 On 5/19/20 6:44 AM, Florian Weimer via Libc-alpha wrote: > This avoids a spurious memory leak report by valgrind. OK for master. Reviewed-by: Carlos O'Donell > --- > nptl/nptlfreeres.c | 1 + > nptl/pthreadP.h | 2 ++ > nptl/pthread_setattr_default_np.c | 10 ++++++++++ > 3 files changed, 13 insertions(+) > > diff --git a/nptl/nptlfreeres.c b/nptl/nptlfreeres.c > index dda11e5922..07aa34adfa 100644 > --- a/nptl/nptlfreeres.c > +++ b/nptl/nptlfreeres.c > @@ -25,6 +25,7 @@ > void > __libpthread_freeres (void) > { > + call_function_static_weak (__default_pthread_attr_freeres); OK. > call_function_static_weak (__nptl_stacks_freeres); > call_function_static_weak (__shm_directory_freeres); > call_function_static_weak (__nptl_unwind_freeres); > diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h > index acc8e88e4a..ed30b72923 100644 > --- a/nptl/pthreadP.h > +++ b/nptl/pthreadP.h > @@ -201,6 +201,8 @@ enum > /* Default pthread attributes. */ > extern union pthread_attr_transparent __default_pthread_attr attribute_hidden; > extern int __default_pthread_attr_lock attribute_hidden; > +/* Called from __libpthread_freeres to deallocate the default attribute. */ > +extern void __default_pthread_attr_freeres (void) attribute_hidden; OK. > > /* Size and alignment of static TLS block. */ > extern size_t __static_tls_size attribute_hidden; > diff --git a/nptl/pthread_setattr_default_np.c b/nptl/pthread_setattr_default_np.c > index c4cfb4e8ef..7a1c644334 100644 > --- a/nptl/pthread_setattr_default_np.c > +++ b/nptl/pthread_setattr_default_np.c > @@ -81,3 +81,13 @@ pthread_setattr_default_np (const pthread_attr_t *in) > lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE); > return ret; > } > + > +/* This is placed in the same file as pthread_setattr_default_np > + because only this function can trigger allocation of attribute > + data. This way, the function is automatically defined for all the > + cases when it is needed in static builds. */ > +void > +__default_pthread_attr_freeres (void) > +{ > + __pthread_attr_destroy (&__default_pthread_attr.external); OK. Delete any internally allocated memory. > +} > -- Cheers, Carlos.