From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eNg1EWbJlGkNOj8AWB0awg (envelope-from ) for ; Tue, 17 Feb 2026 15:02:46 -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=sCziFNfE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 03A6B1E0BA; Tue, 17 Feb 2026 15:02:46 -0500 (EST) 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 E42E91E08D for ; Tue, 17 Feb 2026 15:02:44 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6B0A14BAE7C0 for ; Tue, 17 Feb 2026 20:02:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B0A14BAE7C0 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=sCziFNfE Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 70F6B4BA23D0 for ; Tue, 17 Feb 2026 20:02:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70F6B4BA23D0 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 70F6B4BA23D0 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=1771358526; cv=none; b=n8BPKr8BVSTED6C6z0MAA0Wikc4J6cNR1H37wWb/aQRKefoKXm5haKXekmDz48OlA4tsQ4GDkn4XAIKXXDyHaBDx/sCiW4pDecLMgfTPaeelpsSTs+6LkzMeCt40kz+o6IEXwORzT5NnfyqN+j82CEddLrOIaWm2cpo7qR7AxT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771358526; c=relaxed/simple; bh=vIHw3As8D7CvTBIApRfLc6xQLvY6GiLmCycxQtQmfzI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LNbs9PtD/sLG4UJDfPjFpuUnW1zVDvI9fxG0RdsjrP0yxrzkWvi9d3QsrM+ufgV5FuP6HXpADv4BseHhr4d53T21iHhaaeByN1YvEhmVjAgeGCYMt0EDedkiqlrxfijMC25wr197M6xDMXgyeYnm27kl0GWQhF2NaTSEF0YDqmg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70F6B4BA23D0 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 61HK20KI176109 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Feb 2026 15:02:05 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 61HK20KI176109 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1771358525; bh=uxYXCaFr1QqkwtQ0cpcdpZgc5W7WxyCrWtgwzDu0XCk=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=sCziFNfE6gmgHR+lql0YAPnaaseXhex6SHLFwhBB2kW+nqMcB9TrOOtYaOn51Knr6 myXXjZJuaGvzd6RjmDuNm2HgqkXlWgb/V32fbwpXVvwU4wHlrPlXYQmWuKbeEJPqvD ZgnsVsx5YYnMztgANmvHwHXo4DaqBya/+pmbB2CvWWwYJgkGHKXh3SjeyWs/1iF7nU kRa9aXoHEVcqSTgafEVUo5+b1Dy/G3FKJZbvaMTwx7YNMHEMq8xU9Hzsu8K3o3W56P I6IwY0yHq+Ka+BGZkSCPKOnKJvkCirARrNKCARbyfIzJ4urYtlPDTwp9DeYaMp/eVc WfIvrSnKBkO+g== Received: by simark.ca (Postfix) id 517B01E0EC; Tue, 17 Feb 2026 14:53:32 -0500 (EST) From: simon.marchi@polymtl.ca To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 5/9] gdb/ctf: check return value of ctf_type_align Date: Tue, 17 Feb 2026 14:50:54 -0500 Message-ID: <20260217195329.3833518-6-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260217195329.3833518-1-simon.marchi@polymtl.ca> References: <20260203065435.3092465-1-simon.marchi@polymtl.ca> <20260217195329.3833518-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 17 Feb 2026 20:02:00 +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 c8457a70cf46..ed4a7383427d 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.53.0