From patchwork Tue Apr 13 08:19:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1465616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FVXVaMsk; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FKJSd5lc6z9sVw for ; Tue, 13 Apr 2021 18:20:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CC49396B43D; Tue, 13 Apr 2021 08:20:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CC49396B43D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618302015; bh=+hAJIilJv7lJzGjNZ6P7Ot4R+4e6dQmo0ydTsjyMWy4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FVXVaMskbpJ5VIW91COJiNDWFmanp18743bhLC6kkWN3gCACaKm7unSMCUGMNdSUN +YCZxe7CxlF/rfYepEEe8wE9N9QMjmkyGuO36M3FEXrtI98i6QrNsLI20kXcvRF5wk CMr69fS0HmCHVI7q63sEZgJA8xBLJzfViC9kQVdw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70071.outbound.protection.outlook.com [40.107.7.71]) by sourceware.org (Postfix) with ESMTPS id DD0BE393D013 for ; Tue, 13 Apr 2021 08:20:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DD0BE393D013 Received: from DB6PR0301CA0022.eurprd03.prod.outlook.com (2603:10a6:4:3e::32) by AS8PR08MB7174.eurprd08.prod.outlook.com (2603:10a6:20b:405::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Tue, 13 Apr 2021 08:20:08 +0000 Received: from DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3e:cafe::90) by DB6PR0301CA0022.outlook.office365.com (2603:10a6:4:3e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Tue, 13 Apr 2021 08:20:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT042.mail.protection.outlook.com (10.152.21.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Tue, 13 Apr 2021 08:20:07 +0000 Received: ("Tessian outbound 81a4524e9a48:v90"); Tue, 13 Apr 2021 08:20:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: dc94578adc998d08 X-CR-MTA-TID: 64aa7808 Received: from 8a6d11150931.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 02F2EFF3-C5D3-4F03-844B-618AFCC1C24F.1; Tue, 13 Apr 2021 08:20:01 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8a6d11150931.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 13 Apr 2021 08:20:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qi9NMMx0+728fD1x+0JtLv5W4/nLyCW306FKTs+9IB2jPo9mZIB4avyhTxJVv0z5BR02Lmh1eu2dXLOaI/opBef9/kHridHNpfoyVSBosI3RBAtpcktxTYwdFsDEHNfCnD6BdLY5K+4QOrQYACZR5gWewc66I51QgUI+cTsQ8Ex0MQPJ2sT6hxiDpzpk0IQHtKjHdKg9lFhTI1YyfIywGmJp1ddu/oHU2/pPSXJnwJVXMnO6XEs1L086KJe8a+tPUnADvMdAWyhVhb4PKMp20TtpW6VFIEDczHXw21bayezTL1RKr6vj/SMIgunNyyl66QS4PoQRp+PWJ4OE0wn8Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+hAJIilJv7lJzGjNZ6P7Ot4R+4e6dQmo0ydTsjyMWy4=; b=S7gUEI7WPaRUHF61X150+tm7N4qgrO2t+PQ6/L1aHunccfSchmCtxK2ztpxdR1jLCP4gYfuD547JvcVQmBSHpf1u6A/38TsBoNg0HcD6BHv5rNbDY02x4co0hFiY/yHQuYg7AAWTtvzlMssLQYzF+x3Tx5ZJy/W1Tg7DGAergu1vltdxL5tlJunuvPTyK1q7g3PIP4RHWCsv48bTqTESKpejFmu32ePD3QB0lCvmPXEiP7M7QA1do7ZDohRQ9V6LffyU7N59GkNc53+HD2yERn5Oy/HQZvElykMzeZ0ptKLnYfwStC6tPL/zwdEvKMjw8YfS/zTLkqO5ECwhnNG6fA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PAXPR08MB6558.eurprd08.prod.outlook.com (2603:10a6:102:151::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.22; Tue, 13 Apr 2021 08:20:00 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::c99f:671d:bb2c:f20b]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::c99f:671d:bb2c:f20b%7]) with mapi id 15.20.4020.022; Tue, 13 Apr 2021 08:20:00 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v2 07/14] elf: Add test case for [BZ #19329] Date: Tue, 13 Apr 2021 09:19:53 +0100 Message-Id: <8df69dbc6cc31456a99ef4165fd0eeffc4de4678.1618301209.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: LO2P123CA0045.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::33) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by LO2P123CA0045.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21 via Frontend Transport; Tue, 13 Apr 2021 08:20:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efa29634-70fc-4b56-5d08-08d8fe54f2d0 X-MS-TrafficTypeDiagnostic: PAXPR08MB6558:|AS8PR08MB7174: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XRfIQU3OSMypPfXkPSELFUxtv4mqCHwVLy/sXQE6bnwMezf3wcWZEs71WR5woR+VRUf9DALFGgRfIvF10Fl1tvMU9rELaIDjawsOkLGLWfZ6rYXC6NH2BJi5rF2FRGTUh10ewh9DJwPbgOOnz7LuogC/A1vdLGIkV/TqZxW5uCihOAOFZalAL+ZMiNduEyt+Wi7urrFTLwXdiRauzN6zFV3sBpwY4l0nXXIrc7t4wZlgg8SK/1G9SxKd75Y5Kc51yO2MwvVRXeCfkuXWLEXWi1KUIrvOk9EhzqyoV85bXEpeNtTHnm5Od/6DW5DZj2UW0Z+euJK4tclfbiTNiEFCHPsfCF5RcXm8trxLizmEbYTyEkLPoU0JSaBp/9KGLVuDh0En2tZrQH6iX3yYU52NCaaHYJRYkI4KIcPsMXK1BhRy0PqsxTrORQwKvCFr5tyDG6HUUxX0zaiRulviY129xYC5NaGpLy7TO3+t6PohUsFP/xW0Zj6G7SMqbr9Rl1hC75mhMTwWFnKN02ml7lOLzmh9+s5w0vAJmR1RI9CS0QCWlvWDluK+8Tuhj3r6vZM+WPJQQdILU8DoxJ4wqTdk6Imw5amsPtfWsq+sxwhu29QAj1WllLqU1dPifUDD6SYZzlhJl8ajKnX0hmCzftr+z5PXHQjctT0+8fWgJUS862KodIr04rf1cIMOV0jjliIHGKMdL1X7uJ1002Pr9yqalDydsfc1t+b8I3HxVWsiNEZWGOzSDijnPeloNtAF5dLgOJl0o03MsXJgx+zyRNsL3vtrhcNqdI5rKQKrxBgMpzQ= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(136003)(39860400002)(346002)(396003)(26005)(69590400012)(66556008)(44832011)(316002)(66476007)(6512007)(16526019)(38100700002)(8676002)(66946007)(38350700002)(52116002)(186003)(478600001)(2616005)(86362001)(2906002)(6666004)(5660300002)(6486002)(956004)(6506007)(6916009)(83380400001)(36756003)(8936002)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: IG7nB3PzhCGmQujif5P4i3L3Dh8glnvCa7K8tqI6e3wVJYDvsnxkFQ6gBiItX1g0ZWfbbMVARQTTdXhBbBLIRc34/nhZOEiEEjiKQhgbmI+erACUv35D/0rYwB6Elbi+PXrL6Ma6c5WgI7roVxBXuC2N1CcEmM8oNml07FuzS2CvEk2JasXn7Io6BO/lwWno0OKsld5ooJ1QRp6y6nmNOGSi66p4O/f4LIJWVSmc4dfTJkpoAY6Y8ba/dj3pWJwk82DMf8vQ2RNabeg2QRlZD2UdV4sSpsOxufJQwvApAFvYjpN11UOn3Rtoyt6Uei0GhQOU8FD+SpD/8pRjEfs83fop0CoQp+KxtPnrSYIE9IHgZ2MvJYYjXrvhv1djhc0H2N1tweE1MURxzNtS/H5dGx7eJsLlLaUoQ0032yo6RUtodQnkhcFyObycnBq3BSsKYC0qlmGB42/nP7VlnlBBGF+Qlcysk9a6R1sNKSnahIOVSj6kp92Ex9i/mScA8RYahSUeEZ3j9uueNs2PqP66QN/W9DakRtxfDGRwdaqrmyARWHWWTwawH/NOqGeoDeFAqOgDQQdDV4r0duZv+/lSoaLHh/L0BEfEPZWGVaBtHkRXJ2c3L51xNZkRBtb4QDUAmBVwi00WL3muMR+pYL8vLMIaeUaXcmuEVW8/Uf2JMon/ffLs1AB3Qyjc1bRzUfWMg2fjQ4aB9wghft9Tx2OJSX0EptPv43tBFHHrKCgHLbQdAahvYkRdGAuhDVFaG+jjfgueuBwZjV0ILOBIJZNE74UmNHLzgkDznlekerUBzYtOxqZgS3PTM/rgPutx4Dy1p95tFNXrzOORS9bxTqUARnFiPT1VkfzX2mg/rmnfH1qZCWfBHZQStMX6zvVkxM/8PnBSJcsNcyK54VQGMOqhN4OTx1gbRs74kHkJpSlwumgnetbbOpBelS2ji9FxQrK32t2HB3HT255vFevGY0uHasqbjPfUUwMxxif9KI9UNtpdpCk5m4NHhfLHJhYkYx36cvyDvQeGkvurejua4H8/cyYdI0W0/3HwX+tfGw0jyVd8SvGaHYBh8ctiqBaEZGAkDfB5FQAu2dysItvo8IvaCS1BhcIZTXB2QuJBDtraZVlaUdapGanN2fPaFdrMOdM4Iz0usuBCEMpZ4lx95amSSWxz5PftQImkzQfUGoB9zqZT2yzVpTrpptrA1xxEmjgABw5eX1RudjHYCiPH6b2tLt/VLNKOW08PJUbPYH6tX/VCe8HgTFo5MqiMY+uFdmyyJJodd2HAYw/QeW8O9OeJ433OeKkotk7O/uZZ+nD1O0zYERGjVwLoztmD1AlZHocB X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6558 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ffb5ea80-3345-43b1-7b89-08d8fe54ee4c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N9ciFbXxQ7WOtVgZPA4rQlEsNFXPnGjLQdcFCOtHWtTyOqSX3EGn7w+Tch/HKUjVPPE6sCTQQ4yg47dP/M+4sAbW556st8FccHuxVNijzwc4LTbq631Wi+ge7UxiY+nTV3oyLUhivo1ju3o3GbLs3GmrmMcFLD0nnSsFe0WAOLLJ0InGg+ut5taYdh6wxV/og9ZG+m9viC9WFShmgzZgWm6oyxlnU2xFaz1PHf9T1t/Hc7AVbcTk50pmDBcu+OqCIVdQPgXxN9P1pd9W0xpP6MHQnRiW0mmXRd9tY8VTHRLGIxq38vBSXQbjV+NTwRaK/epidMLV3ynuPvorVBFvn7/WwvsZ5aUt6sEBbfPXi1v9PKzdwkkJ1VCzVG+MdkxXS00QXNE0sYNJIvxk3/v5Q644LAAW/6nX+pibgKB/UK6URrz0oYdpfpVx0Nh2gHkBhUgzUz/VRHvKL2JHhxAkAHdw5WRT1mtmfKTidEmE/qAwCwh77hQ1fatAPhONPCEy44lf77zXAMpaLH44wgjb4LqLOTRBq/lbmAPIuJzWuqej+6sUXWsszlEmTzK5pJlRYtNHXJnRPJRkK8ekN0tQ8jOgz6cSAFOf6Zk++BPikUB8hkh2Nqk00t5gf+Rw8sfJIle/OPKJTWTOHFruayrkgTvKAgzBWhgGl97Dl0ssZxovSdt0CJyuf3+wRBFtKPD31ffrBEOR0JwZVaqD7GlRapTJWSkb9x3+VsJMquFiHjYvk5QO+OXxBTeIS+iR85VHHzdcgxqehddpx3OH/0xuO5jVIeUAgKb6tFrFTDwRlMo= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(396003)(39860400002)(46966006)(36840700001)(356005)(82310400003)(6666004)(16526019)(6512007)(44832011)(36860700001)(186003)(316002)(70586007)(69590400012)(5660300002)(2616005)(956004)(6486002)(336012)(8676002)(81166007)(36756003)(26005)(47076005)(478600001)(8936002)(6916009)(83380400001)(82740400003)(70206006)(2906002)(86362001)(6506007)(2004002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 08:20:07.7304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: efa29634-70fc-4b56-5d08-08d8fe54f2d0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT042.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7174 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY 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-Patchwork-Original-From: Szabolcs Nagy via Libc-alpha From: Szabolcs Nagy Reply-To: Szabolcs Nagy Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Test concurrent dlopen and pthread_create when the loaded modules have TLS. This triggers dl-tls assertion failures more reliably than the nptl/tst-stack4 test. The dlopened module has 100 DT_NEEDED dependencies with TLS, they were reused from an existing TLS test. The number of created threads during dlopen depends on filesystem speed and hardware, but at most 3 threads are alive at a time to limit resource usage. Reviewed-by: Adhemerval Zanella --- v5: - moved from nptl/ to elf/ - use many tls modules from another test (affects the timing a bit as these need more relocation processing, but still detects the race) - use xdlopen - use stdatomic.h - moved from tests-internal back to tests - use acq/rel atomics instead of relaxed, this works too and cleaner. - moved after bug fix patch. v4: - rebased, updated copyright year. - moved to tests-internal because of v3: - use the new test support code. - better Makefile usage so modules are cleaned properly. v2: - undef NDEBUG. - join nop threads so at most 3 threads exist at a time. - remove stack size setting (resource usage is no longer a concern). - stop creating threads after dlopen observably finished. - print the number of threads created for debugging. --- elf/Makefile | 9 ++++-- elf/tst-tls21.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ elf/tst-tls21mod.c | 1 + 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 elf/tst-tls21.c create mode 100644 elf/tst-tls21mod.c diff --git a/elf/Makefile b/elf/Makefile index b1344f1133..e9377608eb 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -223,7 +223,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \ tst-single_threaded tst-single_threaded-pthread \ tst-tls-ie tst-tls-ie-dlmopen argv0test \ tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \ - tst-tls20 + tst-tls20 tst-tls21 # reldep9 tests-internal += loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ @@ -345,7 +345,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \ libmarkermod2-1 libmarkermod2-2 \ libmarkermod3-1 libmarkermod3-2 libmarkermod3-3 \ libmarkermod4-1 libmarkermod4-2 libmarkermod4-3 libmarkermod4-4 \ - tst-tls20mod-bad + tst-tls20mod-bad tst-tls21mod # Most modules build with _ISOMAC defined, but those filtered out # depend on internal headers. @@ -1932,3 +1932,8 @@ tst-tls20mod-bad.so-no-z-defs = yes $(objpfx)tst-tls20: $(libdl) $(shared-thread-library) $(objpfx)tst-tls20.out: $(objpfx)tst-tls20mod-bad.so \ $(tst-tls-many-dynamic-modules:%=$(objpfx)%.so) + +# Reuses tst-tls-many-dynamic-modules +$(objpfx)tst-tls21: $(libdl) $(shared-thread-library) +$(objpfx)tst-tls21.out: $(objpfx)tst-tls21mod.so +$(objpfx)tst-tls21mod.so: $(tst-tls-many-dynamic-modules:%=$(objpfx)%.so) diff --git a/elf/tst-tls21.c b/elf/tst-tls21.c new file mode 100644 index 0000000000..560bf5813a --- /dev/null +++ b/elf/tst-tls21.c @@ -0,0 +1,68 @@ +/* Test concurrent dlopen and pthread_create: BZ 19329. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include + +#define THREADS 10000 + +static atomic_int done; + +static void * +start (void *a) +{ + /* Load a module with many dependencies that each have TLS. */ + xdlopen ("tst-tls21mod.so", RTLD_LAZY); + atomic_store_explicit (&done, 1, memory_order_release); + return 0; +} + +static void * +nop (void *a) +{ + return 0; +} + +static int +do_test (void) +{ + pthread_t t1, t2; + int i; + + /* Load a module with lots of dependencies and TLS. */ + t1 = xpthread_create (0, start, 0); + + /* Concurrently create lots of threads until dlopen is observably done. */ + for (i = 0; i < THREADS; i++) + { + if (atomic_load_explicit (&done, memory_order_acquire) != 0) + break; + t2 = xpthread_create (0, nop, 0); + xpthread_join (t2); + } + + xpthread_join (t1); + printf ("threads created during dlopen: %d\n", i); + return 0; +} + +#include diff --git a/elf/tst-tls21mod.c b/elf/tst-tls21mod.c new file mode 100644 index 0000000000..206ece4fb3 --- /dev/null +++ b/elf/tst-tls21mod.c @@ -0,0 +1 @@ +int __thread x;