This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] libdwfl/cu.c cudie_offset relies on uninitialized type_sig8


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

2012-09-25  Mark Wielaard  <>

        * cu.c (cudie_offset): Don't use type_sig8, it might not be
        initialized and these are always real CUs, never TUs.


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
+ search items.  */
   return DIE_OFFSET_FROM_CU_OFFSET (cu->>start, cu->>offset_size,
-				    cu->>type_sig8 != 0);
+				    0);
 static int

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]