public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/6] [gdb/symtab] Fix uninitialized memory in buildsym_compunit::finish_block_internal
@ 2023-08-30 19:13 Tom de Vries
  2023-08-30 19:13 ` [PATCH 2/6] [gdb/symtab] Factor out type::{alloc_fields,copy_fields} Tom de Vries
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Tom de Vries @ 2023-08-30 19:13 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.dwarf2/per-bfd-sharing.exp with target board stabs,
gdb either segfaults or asserts due to reading uninitialized memory, allocated
here in buildsym_compunit::finish_block_internal:
...
	      ftype->set_fields
		((struct field *)
		 TYPE_ALLOC (ftype, nparams * sizeof (struct field)));
...

Fix this by using TYPE_ZALLOC instead.

Tested on x86_64-linux.

PR symtab/30810
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30810
---
 gdb/buildsym.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 832b689cf03..65ce3a0f5a8 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -267,7 +267,7 @@ buildsym_compunit::finish_block_internal
 	      ftype->set_num_fields (nparams);
 	      ftype->set_fields
 		((struct field *)
-		 TYPE_ALLOC (ftype, nparams * sizeof (struct field)));
+		 TYPE_ZALLOC (ftype, nparams * sizeof (struct field)));
 
 	      iparams = 0;
 	      /* Here we want to directly access the dictionary, because

base-commit: 59487af3c8490bc5961d330bc0ef4d5f05ecdc59
-- 
2.35.3


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

end of thread, other threads:[~2023-08-31  8:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30 19:13 [PATCH 1/6] [gdb/symtab] Fix uninitialized memory in buildsym_compunit::finish_block_internal Tom de Vries
2023-08-30 19:13 ` [PATCH 2/6] [gdb/symtab] Factor out type::{alloc_fields,copy_fields} Tom de Vries
2023-08-30 20:17   ` Tom Tromey
2023-08-31  7:57     ` Tom de Vries
2023-08-30 19:13 ` [PATCH 3/6] [gdb/symtab] Do more zero-initialization of type::fields Tom de Vries
2023-08-30 20:19   ` Tom Tromey
2023-08-30 19:13 ` [PATCH 4/6] [gdb/symtab] Replace TYPE_ALLOC + memset with TYPE_ZALLOC Tom de Vries
2023-08-30 20:20   ` Tom Tromey
2023-08-30 19:13 ` [PATCH 5/6] [gdb/symtab] Replace TYPE_ALLOC + B_CLRALL " Tom de Vries
2023-08-30 20:21   ` Tom Tromey
2023-08-31  8:00     ` Tom de Vries
2023-08-30 19:13 ` [PATCH 6/6] [gdb/symtab] Replace TYPE_ALLOC with TYPE_ZALLOC where required Tom de Vries
2023-08-30 20:26   ` Tom Tromey
2023-08-30 20:15 ` [PATCH 1/6] [gdb/symtab] Fix uninitialized memory in buildsym_compunit::finish_block_internal 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).