From patchwork Tue May 26 11:45:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= X-Patchwork-Id: 135732 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22EF74BA9003 for ; Tue, 26 May 2026 11:45:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22EF74BA9003 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KU0vBqTy X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 976C04BA23D6 for ; Tue, 26 May 2026 11:45:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 976C04BA23D6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 976C04BA23D6 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779795911; cv=none; b=JQFo0SLSM1YAHwSgKd8l1FJEhCpkRrrTcGuQueHaj72pytf1InrJ3RC3JjfF0CsykcE0OQabwGKIJY8AZSoTQ4zWhK3Qz1X83kK8DmjMCyy8ckrID+X+TCbx1ZyLVI6zrz6Rghw98lZS/lrMHhswOrDnz7sTy4GLxzmUDjHT9V0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779795911; c=relaxed/simple; bh=yFGguGJXEEK/VqAFUsCAKqoQNqiTjiN2NDMLNQLijlM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dv2sXajB8v2Mrz8oC6Vj2Irvpp/QyXZXzzTbs/cL9IC6hTgRFhLkgtS70OYcEQpE9wilzva8khFQTWNncFHk9DN8Zyd7gZstEzGW1Z0+NU2W9/tWdQuooDOhc7jpmDc08pkaQNtQE/3CnZysBitZ8EhdpjyPFRXLs3nnsrkG8rs= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KU0vBqTy DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 976C04BA23D6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779795911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nSanbggb8I4xc5OM6SUwEqXVvul3uevmvc3/5V63fd4=; b=KU0vBqTy3gwpxGzlLNofY6t+ZxcML9/tvlEGXcSsZI/3rsxNq0prlkFq+7wv5rh9BXX/qT 6z5ZTPkFnOCZLflOVtDMdTtaRirGxOePjssK0oujIm5mQGGwyiY7uWIg4oA4+vB6QbxzQK dsZzBE5ZlnxH8lIjCgCJYDJ78CfNZzo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-jYLuTap9NqKu_d7QuXshJw-1; Tue, 26 May 2026 07:45:07 -0400 X-MC-Unique: jYLuTap9NqKu_d7QuXshJw-1 X-Mimecast-MFC-AGG-ID: jYLuTap9NqKu_d7QuXshJw_1779795906 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 50A8419560B5; Tue, 26 May 2026 11:45:06 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.44.48.176]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44F511800357; Tue, 26 May 2026 11:45:04 +0000 (UTC) From: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= To: libc-alpha@sourceware.org, adhemerval.zanella@linaro.org Subject: [PATCH] test: Fix and stabilize tst-wcsmbs-clone-overflow test Date: Tue, 26 May 2026 13:45:00 +0200 Message-ID: <20260526114500.1167613-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tf99LH-UaK-OaJaj8tjrszzbN58t1YyfUupEH7Ko7nQ_1779795906 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NONE, TXREP, URIBL_BLOCKED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The test tst-wcsmbs-clone-overflow was initially added to tests-static. However, this causes the test to be unstable because gconv modules dynamically load libc.so. Any discrepancy between the statically linked version and the dynamically loaded one can lead to a crash. By removing the test from tests-static, it relies on dynamic linking, safely bypassing the dlopen crash. Since the test is now dynamically linked, it cannot use the internal thread-local symbol _NL_CURRENT_DATA(LC_CTYPE) because _nl_current_LC_CTYPE is hidden in libc.so, leading to undefined references. Thus, the test now uses newlocale and uselocale, safely extracting the locale data from the returned locale_t object. Furthermore, using newlocale requires the gconv-modules configuration to be built and available so that the ISO8859-1.so module can be dynamically loaded. Otherwise, glibc falls back to the built-in C locale conversions, leaving __shlib_handle as NULL and silently bypassing the reference counter increment. A new Makefile fragment, gen-gconv-modules.mk, is introduced to ensure the gconv-modules are built before the test runs, and an explicit check for __shlib_handle != NULL is added to the test. Reviewed-by: Carlos O'Donell --- gen-gconv-modules.mk | 6 ++++++ localedata/Makefile | 6 ++---- wcsmbs/Makefile | 7 ++----- wcsmbs/tst-wcsmbs-clone-overflow.c | 12 +++++++++--- 4 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 gen-gconv-modules.mk diff --git a/gen-gconv-modules.mk b/gen-gconv-modules.mk new file mode 100644 index 0000000000..046721a7a7 --- /dev/null +++ b/gen-gconv-modules.mk @@ -0,0 +1,6 @@ +# defines target $(gen-gconv-modules) that ensures gconv-modules are available + +gen-gconv-modules := $(common-objpfx)iconvdata/gconv-modules + +$(gen-gconv-modules): + $(MAKE) -C ../iconvdata subdir=iconvdata $@ diff --git a/localedata/Makefile b/localedata/Makefile index 6c9fe7c5c4..0fb1d78c29 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -287,7 +287,7 @@ install-others := $(addprefix $(inst_i18ndir)/, \ $(locales)) endif -tests: $(objdir)/iconvdata/gconv-modules +tests: $(gen-gconv-modules) tests-static += \ tst-langinfo-newlocale-static \ @@ -412,6 +412,7 @@ LOCALES := \ # LOCALES include ../gen-locales.mk +include ../gen-gconv-modules.mk $(objpfx)tst-iconv-emojis-trans.out: $(gen-locales) @@ -587,6 +588,3 @@ $(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out bug-setlocale1-ENV-only = LOCPATH=$(objpfx) LC_CTYPE=de_DE.UTF-8 bug-setlocale1-static-ENV-only = $(bug-setlocale1-ENV-only) - -$(objdir)/iconvdata/gconv-modules: - $(MAKE) -C ../iconvdata subdir=iconvdata $@ diff --git a/wcsmbs/Makefile b/wcsmbs/Makefile index ee3638c0e5..f4f89c030f 100644 --- a/wcsmbs/Makefile +++ b/wcsmbs/Makefile @@ -213,10 +213,6 @@ xtests += test-wcsncmp-nonarray tests-internal += \ tst-wcsmbs-clone-overflow -tests-static += \ - tst-wcsmbs-clone-overflow - - include ../Rules ifeq ($(run-built-tests),yes) @@ -233,6 +229,7 @@ LOCALES := \ zh_TW.EUC-TW \ # LOCALES include ../gen-locales.mk +include ../gen-gconv-modules.mk $(objpfx)tst-btowc.out: $(gen-locales) $(objpfx)tst-c16c32-1.out: $(gen-locales) @@ -247,7 +244,7 @@ $(objpfx)tst-c32-state.out: $(gen-locales) $(objpfx)test-c8rtomb.out: $(gen-locales) $(objpfx)test-mbrtoc8.out: $(gen-locales) $(objpfx)tst-wscanf-to_inpunct.out: $(gen-locales) -$(objpfx)tst-wcsmbs-clone-overflow.out: $(gen-locales) +$(objpfx)tst-wcsmbs-clone-overflow.out: $(gen-locales) $(gen-gconv-modules) endif $(objpfx)tst-wcstod-round: $(libm) diff --git a/wcsmbs/tst-wcsmbs-clone-overflow.c b/wcsmbs/tst-wcsmbs-clone-overflow.c index adfd4fa61d..99461ea087 100644 --- a/wcsmbs/tst-wcsmbs-clone-overflow.c +++ b/wcsmbs/tst-wcsmbs-clone-overflow.c @@ -30,8 +30,11 @@ static int do_test (void) { - if (setlocale (LC_ALL, "de_DE.ISO-8859-1") == NULL) - FAIL_EXIT1 ("setlocale failed, check if de_DE.ISO-8859-1 is generated"); + locale_t loc_obj = newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL); + if (loc_obj == NULL) + FAIL_EXIT1 ("newlocale failed, check if de_DE.ISO-8859-1 is generated"); + + uselocale (loc_obj); wchar_t buf[32] = L"123"; int j; @@ -41,7 +44,7 @@ do_test (void) FAIL_EXIT1 ("swscanf failed"); /* Retrieve the current gconv_fcts from the LC_CTYPE locale data. */ - struct __locale_data *loc = _NL_CURRENT_DATA (LC_CTYPE); + struct __locale_data *loc = loc_obj->__locales[LC_CTYPE]; struct lc_ctype_data *ctype = loc->private; const struct gconv_fcts *fcts = ctype->fcts; @@ -51,6 +54,9 @@ do_test (void) /* Capture the reference counter. */ int initial_counter = fcts->towc->__counter; + if (fcts->towc->__shlib_handle == NULL) + FAIL_EXIT1 ("__shlib_handle is NULL!"); + /* Perform a second iteration of swscanf. If the stack-allocated FILE leaks the gconv reference, the counter will increment. */ if (swscanf (buf, L"%d", &j) < 1)