From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 50FDD3858CDA for ; Sat, 4 Nov 2023 15:56:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50FDD3858CDA 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 50FDD3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699113412; cv=none; b=t7XJDvtapnhQbLsrP0onRyPkEKCYkVwEzx0tjw+WPnMAShcr2YRcQ913ueopkmWdcKNgVpuOb/SI/hbt8UWime8584lnABOZBRveoIDJXgJyRYa57lzLpfzXpErmpaEu/C/VA9wxmtxzIGLalvILkbYa6wXrBZgsJOG/13z6JKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699113412; c=relaxed/simple; bh=6K1C2fzisx9aLiR4c+BWqKXBAgR2NDnCBZtKpzknulE=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-Id: MIME-Version; b=pm/9DcXH1U/bRUeputn7R5p4BJHane4qCDxtMoG/4Ecc3gIPMtexQj+fBOmF+FpmxWIW/W97dHDpTCVIlbV89cABVBv2qRQMxv1ks+C7W06agUAo8gXm+W7+5RwZ/QI0w0pbTK6IwSzE+Wh+FvphCUbC2/wXRVhqdktJ7LzCVWE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7B7642184B for ; Sat, 4 Nov 2023 15:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1699113409; 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=W4cKyRZSCRyTKQQ/9ud3JUrV6Ctkr4oyBzTXZlzENkw=; b=B9yCvXWxAI9JP2NkD2hH+GjgkgHILlZ9fJExgF4sDA+nlxRC37gF1QSFFiMprAHuEtOcSK BMQ3E9NkIy4QwJyW5VoduOoKNTRTYrd1SKcFVrtuukZLLyjldR5544duyavQPyrMdBh3s1 Io27Qnkina7b+nd/nwsByLxTMKHa4ak= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1699113409; 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=W4cKyRZSCRyTKQQ/9ud3JUrV6Ctkr4oyBzTXZlzENkw=; b=CN6OhDEC3RJ5/O2KMz6MYQIsBeTAZG+99i/NdDNjXrQAF8ZMFm9Jc+rcDCMy5KgXn+wQk7 u+TzTssyy2huztBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 67F45138F3 for ; Sat, 4 Nov 2023 15:56:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id meQQGMFpRmXJLgAAMHmgww (envelope-from ) for ; Sat, 04 Nov 2023 15:56:49 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 0/2] [gdb] Fix segfault in for_each_block Date: Sat, 4 Nov 2023 16:57:55 +0100 Message-Id: <20231104155757.16649-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 patch series fixes PR gdb/30547, a segfault when running test-case gdb.base/vfork-follow-parent.exp on powerpc64 (likewise on s390x). There are two patches, each of them by themselves sufficient to no longer trigger the segfault. The root cause of the problem is that linux_is_uclinux, and consequently gdbarch_has_shared_address_space returns an incorrect value. The first patch makes gdb more robust against gdbarch_has_shared_address_space returning incorrect values, by eliminating a call to it. The second patch addresses the root cause. Tested on top of trunk on x86_64-linux and ppc64le-linux. Tested on top of gdb-14-branch on ppc64-linux. [ I used gdb-14-branch for ppc64-linux, because I can't build trunk anymore with system gcc 4.8.5 (CentOS-7), due to the recent c++17 requirement (and just before that, some gcc bug in atomic support), and that's all I have readily available on that machine. ] There is still scope to fix things further. When I started to investigate, I noticed that I only ran into the segfault on ppc64 and s390x, two big-endian architectures, so I sort of expected to find an endian-related problem. Instead, the problem was ppc_linux_target_wordsize returning 4 instead of 8, which causes gdb to interpret the 8-byte entry auxv vector using 4-byte words, causing an incorrect linux_is_uclinux == true. The same problem happens on ppc64le (ppc_linux_target_wordsize returns 4), it's just that the incorrect word size doesn't change the outcome of: - target_auxv_search (AT_NULL, &dummy) == 1, and - target_auxv_search (AT_PAGESZ, &dummy) == 1 so linux_is_uclinux returns false, as it should. This suggest a too forgiving parsing of the auxv vector, which should be made more strict. Finally, it should be fixed that ppc_linux_target_wordsize returns 4 in a process with wordsize == 8. I added an assert that PTRACE_PEEKUSER doesn't fail (errno != 0) and ran into it in test-case gdb.base/access-mem-running.exp, during trying to "set a breakpoint while the process is running". It's clear that it's quite common for this to happen, and it's surprising that this doesn't cause more problems. I'll eventually file PRs for these two issues, for now my interest is to backport at least one, possibly both patches from this series to fix this PR on the gdb 14 release branch (and the 13.2 based distro packages I maintain). Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547 Tom de Vries (2): [gdb] Fix segfault in for_each_block, part 1 [gdb] Fix segfault in for_each_block, part 2 gdb/infrun.c | 12 +++++++++++- gdb/progspace.c | 37 +++++++++++++++++++++++++++---------- gdb/progspace.h | 11 ++++++++++- 3 files changed, 48 insertions(+), 12 deletions(-) base-commit: de2efa143e3652d69c278dd1eb10a856593917c0 -- 2.35.3