From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 244143858D32 for ; Mon, 29 Aug 2022 14:47:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 244143858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id A173F1F8CA; Mon, 29 Aug 2022 14:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661784455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PrHviWe7ZBpgtGZuvk0seDjQ29torh9A8oJqMEQT6oE=; b=1Q8/4DZqUGUOatQ9BzrzusJBnzxWzUQHZunrFB7fuDTp2Zm2FfP6MiaVCdQGQBpK/nEjn2 HLSh5zMJh8Un9932ySJc26R4gsApElaeOV4XXTnZ3DfDmeH0OB2qhsg53SefrQ45GVvbAo hlEHfQubco4uGv0qfgXafMVBQxhZUC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661784455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PrHviWe7ZBpgtGZuvk0seDjQ29torh9A8oJqMEQT6oE=; b=qMGitVKW0i7vvX/IrAr+yFfecaHQL6vWssUVuXN3WzAvOBdKkae+hoOvdNUggza7rfX/kS zJGAmunqaA6ICPBg== Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 9B78F2C141; Mon, 29 Aug 2022 14:47:35 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id 1D838444AFD; Mon, 29 Aug 2022 16:47:34 +0200 (CEST) From: Andreas Schwab To: Florian Weimer Cc: libc-alpha@sourceware.org Subject: [PATCH] Add test for bug 29530 References: <87k06r2lmd.fsf@oldenburg.str.redhat.com> X-Yow: PIZZA!! Date: Mon, 29 Aug 2022 16:47:34 +0200 In-Reply-To: <87k06r2lmd.fsf@oldenburg.str.redhat.com> (Florian Weimer's message of "Mon, 29 Aug 2022 16:02:50 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This tests for a bug that was introduced in commit edc1686af0 ("vfprintf: Reuse work_buffer in group_number") and fixed as a side effect of commit 6caddd34bd ("Remove most vfprintf width/precision-dependent allocations (bug 14231, bug 26211)."). --- stdio-common/Makefile | 2 ++ stdio-common/tst-grouping2.c | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 stdio-common/tst-grouping2.c diff --git a/stdio-common/Makefile b/stdio-common/Makefile index b1e9144de0..e11aaedd96 100644 --- a/stdio-common/Makefile +++ b/stdio-common/Makefile @@ -174,6 +174,7 @@ tests := \ tst-fwrite \ tst-gets \ tst-grouping \ + tst-grouping2 \ tst-long-dbl-fphex \ tst-memstream-string \ tst-obprintf \ @@ -295,6 +296,7 @@ $(objpfx)bug14.out: $(gen-locales) $(objpfx)scanf13.out: $(gen-locales) $(objpfx)test-vfprintf.out: $(gen-locales) $(objpfx)tst-grouping.out: $(gen-locales) +$(objpfx)tst-grouping2.out: $(gen-locales) $(objpfx)tst-sprintf.out: $(gen-locales) $(objpfx)tst-sscanf.out: $(gen-locales) $(objpfx)tst-swprintf.out: $(gen-locales) diff --git a/stdio-common/tst-grouping2.c b/stdio-common/tst-grouping2.c new file mode 100644 index 0000000000..3024c942a6 --- /dev/null +++ b/stdio-common/tst-grouping2.c @@ -0,0 +1,39 @@ +/* Test printf with grouping and large width (bug 29530) + Copyright (C) 2022 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 + +static int +do_test (void) +{ + const int field_width = 1000; + char buf[field_width + 1]; + + xsetlocale (LC_NUMERIC, "de_DE.UTF-8"); + + /* This used to crash in group_number. */ + TEST_COMPARE (sprintf (buf, "%'*d", field_width, 1000), field_width); + TEST_COMPARE_STRING (buf + field_width - 6, " 1.000"); + + return 0; +} + +#include -- 2.37.2 -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."