From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Fix crash in f-typeprint.c
Date: Sat, 13 Sep 2025 13:48:11 -0600 [thread overview]
Message-ID: <20250913194811.933550-1-tom@tromey.com> (raw)
I noticed a crash in f-typeprint.c that was hidden by an xfail:
XFAIL: gdb.fortran/vla-array.exp: print variable length string array type (GDB internal error) (PRMS gcc/101826)
I think this was introduced by commit 6594ca4a ("do not handle a NULL
linebuffer in pager_file::puts") but not detected due to the xfail.
It seems bad for an xfail to cover up a crash but I haven't
investigated that.
Meanwhile, this patch fixes the crash by checking for a NULL pointer
when calling gdb_puts.
---
gdb/f-typeprint.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index e96d27c537e..65c58b59b2d 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -414,7 +414,8 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
gdb_puts (" ", stream);
- gdb_puts (type->name (), stream);
+ if (type->name () != nullptr)
+ gdb_puts (type->name (), stream);
/* According to the definition,
we only print structure elements in case show > 0. */
@@ -432,7 +433,8 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
gdb_puts ("\n", stream);
}
gdb_printf (stream, "%*sEnd Type ", level, "");
- gdb_puts (type->name (), stream);
+ if (type->name () != nullptr)
+ gdb_puts (type->name (), stream);
}
break;
--
2.49.0
next reply other threads:[~2025-09-13 19:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 19:48 Tom Tromey [this message]
2025-09-13 21:48 ` Kevin Buettner
2025-09-13 22:29 ` Tom Tromey
2025-09-15 16:26 ` Kevin Buettner
2025-09-20 20:58 ` Tom Tromey
2025-09-23 0:50 ` Kevin Buettner
2025-09-23 18:27 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250913194811.933550-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox