From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kbWXMVKdgWmKYCUAWB0awg (envelope-from ) for ; Tue, 03 Feb 2026 02:01:38 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=uOnqyVzx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C3D1F1E0BA; Tue, 03 Feb 2026 02:01:38 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.6 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,RDNS_NONE autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (unknown [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 32A951E089 for ; Tue, 03 Feb 2026 02:01:38 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id A6E6D4BA2E09 for ; Tue, 3 Feb 2026 07:01:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6E6D4BA2E09 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=uOnqyVzx Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 647DD4BA2E0A for ; Tue, 3 Feb 2026 07:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 647DD4BA2E0A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 647DD4BA2E0A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770102058; cv=none; b=ZcuiDj0vv1sXTP4+s0Q30W3Knv4xTPpSXPkaJbrA2rTc8shsJ3c3mbtx6L2z8uFiC0h+H6/SUAD4klCjqNc+D0qakcSItRZpMUCpIP1Qyl+G+l2FllmHP1pG2szsIgy4M+dDr+JvUijb57zr8nt1HLi0/lAvj2dEhWoxBgpUzJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770102058; c=relaxed/simple; bh=HmGz8svWFw475T6i+hzUJpQnQ2r+rlHI2QdRI3QSU/E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=STOsIZi3QLnk8sLNT8/lLtJnKqYZHDZlBO1/I2hq10+1qHYglzUz1i/PMgCx3wSJ1g4ZVihfLfMzFqsnD7/tlTJO2WuTl1xPiYV16ZseTZlH1N38Lhg85Su4AGtwvX0LaHVktCaRbHGzrzjJs4nMhXK0NbQncYFRh5BTRVzYUks= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 647DD4BA2E0A Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 61370ofe181544 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 3 Feb 2026 02:00:55 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61370ofe181544 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1770102055; bh=E4169q/D8e4sBixObc9b6VOZr0wTU0aL6NA3AbrB3/4=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=uOnqyVzxJzUMySweVmuLtUkeEsddO1Hq7W4fii/P6GNnkcEcLYcAQiPyeG3tSH1OY ikgOyZ4DpMCv3ThuIsL8Ki+OANFzU0fafMQwmMW+8ZF3NLXskkr742JBmcSah7hTnj WtlKSZv2kkKQn5XaevZ7rfxOxz2cN5VAhFBlNSgP1mxJ9Ztu7eh5vBy0YusX4nEhAy DZ1Ze1IAjI8y9D4lKpAwN59CQlCgnMT8ab7kZxb1/lhPZvClImu5VwyVFFj9tzOR2i JD5O79+utVEPUuhZ56d873tnM2XtPgq9WhSCxu0kc7RT5UF2srD1Cs08glyu7jtYfq uByIktlctbeZg== Received: by simark.ca (Postfix) id 886EB1E0EC; Tue, 03 Feb 2026 01:54:38 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Nick Alcock , Weimin Pan , Simon Marchi Subject: [RFC PATCH 5/8] gdb/ctf: check return value of ctf_type_align Date: Tue, 3 Feb 2026 01:45:46 -0500 Message-ID: <20260203065435.3092465-6-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260203065435.3092465-1-simon.marchi@polymtl.ca> References: <20260203065435.3092465-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 3 Feb 2026 07:00:50 +0000 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 From: Simon Marchi I tried to build the Linux kernel with -gctf. I am not sure if the result is good, because I got plenty of warnings like: ld: warning: orphan section `.ctf' from `vmlinux.o' being placed in section `.ctf' Nevertheless, I tried to load it in GDB, and it didn't complain. However, when doing "maint expand-symtabs", I did hit this assert: /home/simark/src/binutils-gdb/gdb/gdbtypes.c:3640: internal-error: set_type_align: Assertion `(align & (align - 1)) == 0' failed. This is because ctf_type_align returns -1 for some types, which is an indication of an error. Update the code to check the return value of ctf_type_align for errors, and emit complaints if it happens. With this patch, if I enable the complaints, I see a bunch of messages like this: During symbol reading: ctf_type_align read_structure_type failed - Type is not a complete type. Change-Id: Ibed23e7f1490d9163b8dde1318b9e45dec2906d6 --- gdb/ctfread.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/gdb/ctfread.c b/gdb/ctfread.c index b2557ac31717..971742dba7b3 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -616,7 +616,14 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid) type->set_code (TYPE_CODE_STRUCT); type->set_length (ctf_type_size (dict, tid)); - set_type_align (type, ctf_type_align (dict, tid)); + + if (ssize_t align = ctf_type_align (dict, tid); + align >= 0) + set_type_align (type, align); + else + complaint (_("ctf_type_align read_structure_type failed - %s"), + ctf_errmsg (ctf_errno (dict))); + return set_tid_type (objfile, tid, type); } @@ -673,7 +680,13 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) } rettype = fetch_tid_type (ccp, cfi.ctc_return); type->set_target_type (rettype); - set_type_align (type, ctf_type_align (dict, tid)); + + if (ssize_t align = ctf_type_align (dict, tid); + align >= 0) + set_type_align (type, align); + else + complaint (_("ctf_type_align read_func_kind_type failed - %s"), + ctf_errmsg (ctf_errno (dict))); /* Set up function's arguments. */ argc = cfi.ctc_argc; @@ -723,7 +736,13 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid) type->set_length (ctf_type_size (dict, tid)); /* Set the underlying type based on its ctf_type_size bits. */ type->set_target_type (objfile_int_type (objfile, type->length (), false)); - set_type_align (type, ctf_type_align (dict, tid)); + + if (ssize_t align = ctf_type_align (dict, tid); + align >= 0) + set_type_align (type, align); + else + complaint (_("ctf_type_align read_enum_type failed - %s"), + ctf_errmsg (ctf_errno (dict))); return set_tid_type (objfile, tid, type); } @@ -814,7 +833,12 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid) else type->set_length (ctf_type_size (dict, tid)); - set_type_align (type, ctf_type_align (dict, tid)); + if (ssize_t align = ctf_type_align (dict, tid); + align >= 0) + set_type_align (type, align); + else + complaint (_("ctf_type_align read_array_type failed - %s"), + ctf_errmsg (ctf_errno (dict))); return set_tid_type (objfile, tid, type); } @@ -936,7 +960,13 @@ read_pointer_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) } type = lookup_pointer_type (target_type); - set_type_align (type, ctf_type_align (ccp->dict, tid)); + + if (ssize_t align = ctf_type_align (ccp->dict, tid); + align >= 0) + set_type_align (type, align); + else + complaint (_("ctf_type_align read_pointer_type failed - %s"), + ctf_errmsg (ctf_errno (ccp->dict))); return set_tid_type (objfile, tid, type); } -- 2.52.0