From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SUunARNnommbWQ0AWB0awg (envelope-from ) for ; Fri, 27 Feb 2026 22:54:59 -0500 Received: by simark.ca (Postfix, from userid 112) id E779B1E0E1; Fri, 27 Feb 2026 22:54:58 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, 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 1DED81E08D for ; Fri, 27 Feb 2026 22:54:57 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 93EA14BAD153 for ; Sat, 28 Feb 2026 03:54:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93EA14BAD153 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id CC6DE4BA23CB for ; Sat, 28 Feb 2026 03:54:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC6DE4BA23CB Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CC6DE4BA23CB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772250869; cv=none; b=NH+lHTOYL94h2JxvCLRS7BGGHxpEiBPwIpWFSpw/g9wZ7Ofut4J0jrHwkJaV0TDQDSM4t8eyH2T4wArAsB2mI4RIaj9UZ8Wo7wc+idSUk/QvZEejGeeg4gTFyR8YVA6CiSc5phCUhu2tLA2ySRX4nO0G0VKn4YcdnbphtNIK8XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772250869; c=relaxed/simple; bh=vIHw3As8D7CvTBIApRfLc6xQLvY6GiLmCycxQtQmfzI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cE1K0TF0YPImjW7xaGD5gUtKVc/Q8njxNplA1GsfBH7DjSOwvOg3qDG74sYXUrp9I+usSjinTSInk4g+h9AEF9cLj5g4Vdm0Vnaz1jJM5o9lIEa+8dGJanSAmdG1bfUiRYdEOpF8DsjxC4Kw65SMZ4DK2qV/lJjIRekoKSJ27mQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC6DE4BA23CB Received: by simark.ca (Postfix) id 6D6761E0EC; Fri, 27 Feb 2026 22:54:28 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v3 5/9] gdb/ctf: check return value of ctf_type_align Date: Fri, 27 Feb 2026 22:51:52 -0500 Message-ID: <20260228035425.422765-6-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260228035425.422765-1-simon.marchi@efficios.com> References: <20260217195329.3833518-1-simon.marchi@polymtl.ca> <20260228035425.422765-1-simon.marchi@efficios.com> 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 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