From patchwork Tue Apr 9 11:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1082138 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=kalray.eu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kalray.eu header.i=@kalray.eu header.b="CVXwI4pM"; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44dkqH0GyVz9sDX for ; Tue, 9 Apr 2019 21:00:56 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id EEFF510117; Tue, 9 Apr 2019 13:00:48 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from zimbra2.kalray.eu (zimbra2.kalray.eu [92.103.151.219]) by helium.openadk.org (Postfix) with ESMTPS id 198CC10115 for ; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id BB4D927E0492 for ; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sqkbr0ZFaS80; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 5AF3627E0491; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 5AF3627E0491 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1554807646; bh=a0M6aAwjg1/IaJKgnMi/yiRAXKXPvIkrNbF3aRzWRaA=; h=From:To:Date:Message-Id:MIME-Version; b=CVXwI4pMzMKO5uvtUezXtVdiBvzEUem+UwJc3QR0B/7Ts90hrz4B7dold1sbt5S6B 3rVsqFpEF1iMEvi0B5ZyWV8GTyzWAGjxabtK3xJwBxCzC3z/eAZ33ViDNqqXBVtDUn /lXy5olTGJOUzy2ry/qdhn1j8qO4oYr2IygsK2XA= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ykFNt2v0-wMS; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 48C8627E02F3; Tue, 9 Apr 2019 13:00:46 +0200 (CEST) From: Yann Sionneau To: devel@uclibc-ng.org Date: Tue, 9 Apr 2019 13:00:43 +0200 Message-Id: <20190409110043.23642-1-ysionneau@kalray.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [uclibc-ng-devel] [PATCH] Fix _dl_deallocate_tls in !SHARED case X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" This patch seems needed in builds where - SHARED is not defined (no shared lib support) - and USE_TLS is set Without this patch, static_dtv is free'ed. See the following backtrace: This backtrace is obtained while debugging tst-basic3 from the uclibc-ng nptl testsuite. It aborts because of the assert in malloc: https://elixir.bootlin.com/uclibc-ng/v1.0.31/source/libc/stdlib/malloc-standard/malloc.c#L80 Signed-off-by: Yann Sionneau --- libpthread/nptl/sysdeps/generic/dl-tls.c | 5 +++++ libpthread/nptl/sysdeps/generic/libc-tls.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c index 989e587a2..7d25e4706 100644 --- a/libpthread/nptl/sysdeps/generic/dl-tls.c +++ b/libpthread/nptl/sysdeps/generic/dl-tls.c @@ -48,6 +48,9 @@ /* Value used for dtv entries for which the allocation is delayed. */ # define TLS_DTV_UNALLOCATED ((void *) -1l) +#ifndef SHARED +extern dtv_t static_dtv; +#endif /* Out-of-memory handler. */ # ifdef SHARED @@ -584,6 +587,8 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb) /* The array starts with dtv[-1]. */ #ifdef SHARED if (dtv != GL(dl_initial_dtv)) +#else + if ((dtv - 1) != &static_dtv) #endif free (dtv - 1); diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c index a6df4cdc4..d746c9a38 100644 --- a/libpthread/nptl/sysdeps/generic/libc-tls.c +++ b/libpthread/nptl/sysdeps/generic/libc-tls.c @@ -42,7 +42,10 @@ extern size_t _dl_phnum; extern int __tdata_start; #endif -static dtv_t static_dtv[2 + TLS_SLOTINFO_SURPLUS]; +#ifdef SHARED +static +#endif +dtv_t static_dtv[2 + TLS_SLOTINFO_SURPLUS]; static struct