public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix crash in struct-with-sig-2.exp with debug-names target board
@ 2024-01-17  2:12 Tom Tromey
  2024-01-17 10:29 ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2024-01-17  2:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

When I run the struct-with-sig-2.exp test with the .debug_names-using
target board, I see a gdb crash.  This happens because the reader
throws an exception without calling finalize_all_units.  This causes
an assertion failure later because the number of CUs and TUs doesn't
match.

The fix is to clear 'all_units' on failure.
---
 gdb/dwarf2/read.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 1b5e566bb01..8f2b7a35f27 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5193,6 +5193,8 @@ create_all_units (dwarf2_per_objfile *per_objfile)
 
       if (!dwz->types.empty ())
 	{
+	  per_objfile->per_bfd->all_units.clear ();
+
 	  /* See enhancement PR symtab/30838.  */
 	  error (_("Dwarf Error: .debug_types section not supported in dwz file"));
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix crash in struct-with-sig-2.exp with debug-names target board
  2024-01-17  2:12 [PATCH] Fix crash in struct-with-sig-2.exp with debug-names target board Tom Tromey
@ 2024-01-17 10:29 ` Tom de Vries
  2024-01-17 13:16   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2024-01-17 10:29 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 1/17/24 03:12, Tom Tromey wrote:
> When I run the struct-with-sig-2.exp test with the .debug_names-using
> target board, I see a gdb crash.  This happens because the reader
> throws an exception without calling finalize_all_units.  This causes
> an assertion failure later because the number of CUs and TUs doesn't
> match.
> 
> The fix is to clear 'all_units' on failure.

I see this is my fault, I added this error and forgot to add the clear, 
sorry about that.

Anyway, LGTM.

I've also applied the patch and confirmed that gdb doesn't crash anymore.

Approved-By: Tom de Vries <tdevries@suse.de>

Thanks,
- Tom

> ---
>   gdb/dwarf2/read.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 1b5e566bb01..8f2b7a35f27 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -5193,6 +5193,8 @@ create_all_units (dwarf2_per_objfile *per_objfile)
>   
>         if (!dwz->types.empty ())
>   	{
> +	  per_objfile->per_bfd->all_units.clear ();
> +
>   	  /* See enhancement PR symtab/30838.  */
>   	  error (_("Dwarf Error: .debug_types section not supported in dwz file"));
>   	}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix crash in struct-with-sig-2.exp with debug-names target board
  2024-01-17 10:29 ` Tom de Vries
@ 2024-01-17 13:16   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2024-01-17 13:16 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, gdb-patches

Tom> I see this is my fault, I added this error and forgot to add the
Tom> clear, sorry about that.

I assumed it was my fault from the background reader series :)
I didn't really look though.

Tom> I've also applied the patch and confirmed that gdb doesn't crash anymore.
Tom> Approved-By: Tom de Vries <tdevries@suse.de>

Thanks.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-17 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17  2:12 [PATCH] Fix crash in struct-with-sig-2.exp with debug-names target board Tom Tromey
2024-01-17 10:29 ` Tom de Vries
2024-01-17 13:16   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).