This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFA: fix uninitialized field in Ada code
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 12 Dec 2011 09:22:48 -0700
- Subject: RFA: fix uninitialized field in Ada code
Joel, could you review this?
While running valgrind on some regressions caused by a patch series I'm
developing, I came across this:
==16492== Conditional jump or move depends on uninitialised value(s)
==16492== at 0x77C4CE: aux_add_nonlocal_symbols (ada-lang.c:4851)
==16492== by 0x6B9C54: map_matching_symbols_psymtab (psymtab.c:1245)
==16492== by 0x77C778: add_nonlocal_symbols (ada-lang.c:4933)
==16492== by 0x77CA9A: ada_lookup_symbol_list (ada-lang.c:5033)
==16492== by 0x77CCDC: ada_lookup_encoded_symbol (ada-lang.c:5111)
==16492== by 0x77CD68: ada_lookup_symbol (ada-lang.c:5136)
==16492== by 0x77CDA0: ada_lookup_symbol_nonlocal (ada-lang.c:5146)
==16492== by 0x6B1111: lookup_symbol_aux (symtab.c:1265)
==16492== by 0x6B0ED1: lookup_symbol_in_language (symtab.c:1157)
==16492== by 0x6B0F22: lookup_symbol (symtab.c:1171)
==16492== by 0x6CA770: decode_label (linespec.c:2598)
==16492== by 0x6C7605: decode_line_internal (linespec.c:1114)
The bug is that data->found_sym is not initialized by
add_nonlocal_symbols.
This silences valgrind, but I am not certain whether it is the correct
fix.
You can reproduce the problem by running gdb.ada/exec_changed.exp with
valgrind.
Tom
2011-12-12 Tom Tromey <tromey@redhat.com>
* ada-lang.c (add_nonlocal_symbols): Initialize data.found_sym.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 33d7253..dc2e7b8 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4924,6 +4924,7 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
data.obstackp = obstackp;
data.arg_sym = NULL;
+ data.found_sym = 0;
ALL_OBJFILES (objfile)
{