This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[Patch] libdwfl/cu.c cudie_offset relies on uninitialized type_sig8
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 25 Sep 2012 13:36:08 +0200
- Subject: [Patch] libdwfl/cu.c cudie_offset relies on uninitialized type_sig8
Hi,
Another thing valgrind caught:
==19596== Conditional jump or move depends on uninitialised value(s)
==19596== at 0x4E4E8F1: compare_cukey (cu.c:154)
==19596== by 0x536949E: tsearch (tsearch.c:260)
==19596== by 0x4E4E9DB: intern_cu (cu.c:173)
==19596== by 0x4E4EC4D: __libdwfl_nextcu (cu.c:265)
==19596== by 0x4E4EFF0: dwfl_nextcu (dwfl_nextcu.c:51)
==19596== by 0x400AFB: main (low_high_pc.c:99)
==19596== Uninitialised value was created by a stack allocation
==19596== at 0x4E4E980: intern_cu (cu.c:167)
Again valgrind is right, in libdwfl/cu.c cudie_offset () we use the cu
die type_sig8, which is never setup for the tsearch search key. The
simplest fix seems to be to just say this is never a TU here (the
alternative fix would be to initialize dwkey.type_sig8 to zero in
intern_cu).
2012-09-25 Mark Wielaard <mjw@redhat.com>
* cu.c (cudie_offset): Don't use type_sig8, it might not be
initialized and these are always real CUs, never TUs.
Cheers,
Mark
diff --git a/libdwfl/cu.c b/libdwfl/cu.c
index 2e98568..18fc206 100644
--- a/libdwfl/cu.c
+++ b/libdwfl/cu.c
@@ -151,8 +151,12 @@ less_lazy (Dwfl_Module *mod)
static inline Dwarf_Off
cudie_offset (const struct dwfl_cu *cu)
{
+ /* These are real CUs, so there never is a type_sig8. Note
+ initialization of dwkey.start and offset_size in intern_cu ()
+ to see why this calculates the same value for both key and
+ die.cu search items. */
return DIE_OFFSET_FROM_CU_OFFSET (cu->die.cu->start, cu->die.cu->offset_size,
- cu->die.cu->type_sig8 != 0);
+ 0);
}
static int