From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8nhIG+RfRmoGbiIAWB0awg (envelope-from ) for ; Thu, 02 Jul 2026 08:56:04 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=KY8d+/g6; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5CDA81E098; Thu, 02 Jul 2026 08:56:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.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 autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 7FEE81E024 for ; Thu, 02 Jul 2026 08:56:03 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 898FF4B9DB44 for ; Thu, 2 Jul 2026 12:56:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 898FF4B9DB44 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=KY8d+/g6 Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) by sourceware.org (Postfix) with ESMTPS id 610844BA2E0A for ; Thu, 2 Jul 2026 12:55:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 610844BA2E0A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 610844BA2E0A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782996938; cv=none; b=pvjnPjYWJR1VwzrjPt2mVDidOZ288NkvtG4O3BXyqqeNlRgXn5V0jvRxJzTRzzbQmD1w0NdAve7cTMxg+nSdQrQdG7dpv3ooEmv0OMEqc9mIR03i5tOT5ywWD9d6kO0TwXKvO4Pbi1ovjj9m1AFWSKN6yv8iQUrGQtjIzUkvHtc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782996938; c=relaxed/simple; bh=5UrBiCLhH2FH0w6TyVTpvlwN0ew/HLGajKZONXqDgP4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=KkoipnJHVWwHSzaAW9VlEgeZsaIrdwkHi+OEfUS68AOxmSVXhQH0TWQ1GI+5zeA2VDqnR88rc4JaG+yXSKHUUBG/U8u/ogAiLsnQl6mTgXPN6epCLd63MAi2sBTUs4YdFC6ywTL8/aXHlcUGJt40fKr7I9qy56jqUtRmO67dnkY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=KY8d+/g6 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 610844BA2E0A Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-6a1900d08f4so284917eaf.0 for ; Thu, 02 Jul 2026 05:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1782996938; x=1783601738; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bS5uM1Hx7GboXVfRO2Au+HIOt7DqtGNeA4zIa/VCc04=; b=KY8d+/g6ZiV6dSfWLtRtlWVtZKfPI2hMCtAwNMA+0TWR2EF+QvetL16959V+O3dB8I f/ePUYQ0tNU5to3EvzIJxlCdPRX3UWbgL6LPe6cjKU1RPKFslkD2AEGvbeVcr6p/E/wQ N1fRtI9j+HpCJwHVvq62aWQ0XJwT2rwrmemo7P8tS23jVvjPHqJXmSUW5I5ZriMmmcZe qlKIPzm1AaQewTZP5pzuU6ziyA5sEaG2BLPeLGtqyiaORWAfsUWl12MaVRYPmK2ttU7H DEvIETpdi47tDKhdjw6M66cp4i+TwdO20zOpsIjpDnh3EyxeKB+agfSqHP9X6hzpqh/q pvaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782996938; x=1783601738; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bS5uM1Hx7GboXVfRO2Au+HIOt7DqtGNeA4zIa/VCc04=; b=Au34h9zuMBRlQ6Zdb4sEylVy1wygGch+gO5eHLEE6UsMNej4FeKc5yFeB5Ibequhmj eSCR1Gf++eR4S/YPRp5AW3bC2BuQx8fuq/kou7ZvHIVeHfD0UAVxE/4H8Vbnao44RSQj 753pDSyEETwg3Wz7ejbTVoP+yndaJzupigWS1tUv5P7VgfHYJgKJ+z+YYWMNncLJH6xy GklDZE2hElKAaI9l/NLPZn62TqLMBPyklhkuNhmEnLkNZyO57mon29ErIclgofKs75Jl STqWMFFDspuN5sNAktcWJ9AEJKVp2tJgIf0hjFmQoMjp6AyoxjvYcSu4xxu2jh+jatoU en1Q== X-Gm-Message-State: AOJu0YzCFdsouug2OTKlsmR6QmlugkOB19+fi7CPtKxDrvSE1lYsI9nr U/x4CLEr3vah3pFrBBixJZ03QrE2f74EO1IKbLVHi50LER/0Q0F7rGbj9CCNCZcCtkhOPJk+JXZ Lp7o= X-Gm-Gg: AfdE7cmygG75GY/bHWwqpE4nSnJvlklUeWNLRAoh686lu3ghQ5tHHCFb68Z8MpsJ3yb T+muo0LIABSVy4pKQS5uk6wnccLmZYkYmD1F2zyJccQHMAY5AAUsbElutQqYihGueizUYICRxfA AdMdWnXt2hb6IzqqjgjvgGZXkhqreKrD5Q/8KsPeKrUotWIzuDBIVDCU08xflRftfv15MSVuN2S C/SthgMgitROU5JKyrUu56rjcTk71B04F/2c732zr8pRq6MARl/kXELXng1R+4/L9XP83H0MBiK U66zIxWQB8BM5/FMo/I/wPdCU2806lhUEOM6hKXoxd72bcc8WdRYhLOsayXSMH27Jp2VvwAOD/b 6YGzVM4IGFzzqVa3L5OzimCRThiUatYsmgNe0NNm8OC9dEe6TPGKqigZwPclTkdwd0B27CehPse 7SmoWa2wWtD92SKMQVb6gx034XxbfFwxhH X-Received: by 2002:a05:6820:4def:b0:6a2:4ee8:823f with SMTP id 006d021491bc7-6a3090c1785mr2846883eaf.36.1782996937696; Thu, 02 Jul 2026 05:55:37 -0700 (PDT) Received: from bapiya (75-166-225-82.hlrn.qwest.net. [75.166.225.82]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6a310003927sm1910561eaf.6.2026.07.02.05.55.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2026 05:55:37 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Fix ptid_t selftest crash Date: Thu, 2 Jul 2026 06:55:34 -0600 Message-ID: <20260702125534.2381813-1-tromey@adacore.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Sam James pointed out that my recent patch to add ptid_t::parse caused a selftest crash. At first I couldn't see why this did not crash for me, but then I realized that ptid_t::parse didn't unconditionally initialize '*obuf'. Initializing it to nullptr made this crash reliably. The underlying bug is that some code paths in ptid_t::parse don't set obuf on return. This patch fixes the bug by passing 'obuf' down to hex_or_minus_one. Since this is straightforward and fixes a new crash, I'm checking it in. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34340 --- gdb/unittests/ptid-selftests.c | 2 +- gdbsupport/ptid.cc | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gdb/unittests/ptid-selftests.c b/gdb/unittests/ptid-selftests.c index c02401db952..b52c98cdc54 100644 --- a/gdb/unittests/ptid-selftests.c +++ b/gdb/unittests/ptid-selftests.c @@ -154,7 +154,7 @@ static_assert (!ptid_t (2, 2, 2).matches (both), static ptid_t parse_one (const char *str, bool for_remote) { - const char *out; + const char *out = nullptr; ptid_t result = ptid_t::parse (str, &out, for_remote, [] () { diff --git a/gdbsupport/ptid.cc b/gdbsupport/ptid.cc index 731a5bc3da3..5de1da3ba44 100644 --- a/gdbsupport/ptid.cc +++ b/gdbsupport/ptid.cc @@ -119,7 +119,7 @@ ptid_t::parse (const char *buf, const char **obuf, bool for_remote, } /* No multi-process. Just a thread id. */ - hex = hex_or_minus_one (p, &pp, for_remote); + hex = hex_or_minus_one (p, obuf, for_remote); /* Handle special thread ids. */ if (hex == (ULONGEST) -1) @@ -134,8 +134,5 @@ ptid_t::parse (const char *buf, const char **obuf, bool for_remote, pid = default_pid (); - if (obuf != nullptr) - *obuf = pp; - return ptid_t (pid, lwp); } base-commit: c2d4b5e1135f75f7e4ef7ff68fa899bfe483671b -- 2.54.0