From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id J/ziGcNF3mmd6xYAWB0awg (envelope-from ) for ; Tue, 14 Apr 2026 09:48:51 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dqIJISEu; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=G+L+TCnS; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dqIJISEu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=G+L+TCnS; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 54EEF1E08C; Tue, 14 Apr 2026 09:48:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1E2E31E08C for ; Tue, 14 Apr 2026 09:48:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 818EF4BA23D7 for ; Tue, 14 Apr 2026 13:48:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 818EF4BA23D7 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dqIJISEu; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=G+L+TCnS; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=dqIJISEu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=G+L+TCnS Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id AE3BB4BA2E07 for ; Tue, 14 Apr 2026 13:48:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE3BB4BA2E07 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE3BB4BA2E07 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776174503; cv=none; b=iQJgpTrvIhoYeFj7urf0+c1ax9XWL4AqqSVgY0B6QUa++FlRPhJTMhelTE9PX73uSRZl1Apm8u9J8AjaYQIjFyLQQi/fuaF+0tGXHfGdEpgBbcaWiAyDZsTd1AQshkDElSqpS1PjBwPWGDrMqq7HkoPx5nKu+zOFHPPuccEfemw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776174503; c=relaxed/simple; bh=Xo665twYHFMaPv4gSKylEWSb1LTHQgXXSJCulAk92Go=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=iXM9B21uguF595cLnNEnm6OoXw1l2kltj+kbdCK3DNpqUy1LFAs0BuMsdPWqH9y2iy0pX17heRdzgzF2GbAaq0KGkIKoTqCs03dNGjpcjLJMq5GuvooCCSZHu2b8WdQs/jk1uiszh4T8Yi1ztsjxaBcM1UcAPuI3fxH8vvdthOI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE3BB4BA2E07 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 9A10A5BDFB for ; Tue, 14 Apr 2026 13:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776174501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QVWad3ASIuqYvgyxibIeXpCjVZEnzaLFF1RaJd9IZvI=; b=dqIJISEupMbB+jifdbNyQZKxlV5kYbRFx/KSmTWI0/Z2YOJg2opAKiy82P5p06xzpqA0w6 iwf9XKOjYfY9PkRirkb74bzbXcwSyvCnqMByF6ks5/K0Q7a/FRD+w0mFT0K0foBUti/HMe fXVzyLAB7Vsf1tev/blY9XLf7Qewszs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776174501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QVWad3ASIuqYvgyxibIeXpCjVZEnzaLFF1RaJd9IZvI=; b=G+L+TCnScWqYw0iPFMTPEPTKkubeZecQXqFW4kPGn5nQ6emJRl3oMTkAZj8cTNf0ZPArsz caszIIMMymvAGmDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1776174501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QVWad3ASIuqYvgyxibIeXpCjVZEnzaLFF1RaJd9IZvI=; b=dqIJISEupMbB+jifdbNyQZKxlV5kYbRFx/KSmTWI0/Z2YOJg2opAKiy82P5p06xzpqA0w6 iwf9XKOjYfY9PkRirkb74bzbXcwSyvCnqMByF6ks5/K0Q7a/FRD+w0mFT0K0foBUti/HMe fXVzyLAB7Vsf1tev/blY9XLf7Qewszs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1776174501; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QVWad3ASIuqYvgyxibIeXpCjVZEnzaLFF1RaJd9IZvI=; b=G+L+TCnScWqYw0iPFMTPEPTKkubeZecQXqFW4kPGn5nQ6emJRl3oMTkAZj8cTNf0ZPArsz caszIIMMymvAGmDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8579D4B492 for ; Tue, 14 Apr 2026 13:48:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 23xaH6VF3mmGVAAAD6G6ig (envelope-from ) for ; Tue, 14 Apr 2026 13:48:21 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/build] Reimplement Wstringop-overread workaround Date: Tue, 14 Apr 2026 15:48:21 +0200 Message-ID: <20260414134821.2638550-1-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,gnu.org:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org While working on commit 391c4026573 ("[gdb] Simplify debuginfod_is_enabled") I noticed this Wstringop-overread workaround: ... url_view = url_view.substr (off); /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on hppa seem convinced url_view might be of SIZE_MAX length. And so complains because the length of an array can only be PTRDIFF_MAX. */ DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD off = url_view.find_first_of (' '); DIAGNOSTIC_POP ... I had difficulty understanding how the warning got triggered, and why it was ok to ignore it, so I investigated this and ended up filing a gcc PR [1]. While doing so, I realized that this: ... - url_view = url_view.substr (off); + url_view = url_view.substr (off, PTRDIFF_MAX); ... is a simpler workaround, that: - is not specific to the warning and also - states explicitly what the assumption is we're making. I ended up using this instead to make the workaround part more minimal: ... url_view = url_view.substr (off); +#if defined (__GNUC__) && !defined (__clang__) + url_view = url_view.substr (0, PTRDIFF_MAX); +#endif off = url_view.find_first_of (' '); ... The gcc PR got closed (because there's no known reproducer with gcc 12 and later), but I use the workaround without version limit, because there's no actual proof that the problem is fixed. Tested on x86_64-linux. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124879 --- gdb/debuginfod-support.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c index 40b816c5a40..b5e790c3b95 100644 --- a/gdb/debuginfod-support.c +++ b/gdb/debuginfod-support.c @@ -249,14 +249,15 @@ debuginfod_is_enabled () if (off == std::string_view::npos) break; url_view = url_view.substr (off); - /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on - hppa seem convinced url_view might be of SIZE_MAX length. - And so complains because the length of an array can only - be PTRDIFF_MAX. */ - DIAGNOSTIC_PUSH - DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD +#if defined (__GNUC__) && !defined (__clang__) + /* With g++ 11, we encounter a Wstringop-overread in + url_view.find_first_of. G++ seems convinced url_view might be of + SIZE_MAX length here. And so complains because the length of an + array can only be PTRDIFF_MAX. Work around this by explicitly + limiting the size of url_view to PTRDIFF_MAX. See PR gcc/124879. */ + url_view = url_view.substr (0, PTRDIFF_MAX); +#endif off = url_view.find_first_of (' '); - DIAGNOSTIC_POP gdb_printf (_(" <%ps>\n"), styled_string (file_name_style.style (), base-commit: 391c4026573aeb1e6e09f36816901f2ade537e1a -- 2.51.0