This is the mail archive of the elfutils-devel@sourceware.org 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] Fix uninitialized Dwarf_Frame->regs


Hi,

this patch is not required for
	[API RFC] unwinder
	https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/002618.html

to PASS and also it has no effect without -lmcheck.

But with this additional testing only patch
------------------------------------------------------------------------------
diff --git a/libdwfl/dwfl_frame_unwind.c b/libdwfl/dwfl_frame_unwind.c
index da9ed34..c0cb7c9 100644
--- a/libdwfl/dwfl_frame_unwind.c
+++ b/libdwfl/dwfl_frame_unwind.c
@@ -518,6 +518,7 @@ handle_cfi (Dwarf_Frame_State **statep, Dwarf_Addr pc, Dwfl_Module *mod,
 	}
       else if (! expr_eval (state, frame, reg_ops, reg_nops, &regval))
 	{
+printf("regno %u fail\n", regno);
 	  /* PPC32 vDSO has various invalid operations, ignore them.  The
 	     register will look as unset causing an error later, if used.
 	     But PPC32 does not use such registers.  */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0beeccd..24725a3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -299,7 +299,7 @@ md5_sha1_test_LDADD = $(libeu)
 typeiter_LDADD = $(libdw) $(libelf) $(libmudflap)
 low_high_pc_LDADD = $(libdw) $(libelf) $(libmudflap)
 test_elf_cntl_gelf_getshdr_LDADD = $(libelf) $(libmudflap)
-backtrace_LDADD = $(libdw) $(libelf) $(libmudflap)
+backtrace_LDADD = $(libdw) $(libelf) $(libmudflap) -lmcheck
 backtrace_child_CFLAGS = -fPIE
 backtrace_child_LDFLAGS = -pie -pthread
 
------------------------------------------------------------------------------
it will print many such errors even during 'cd tests; ./backtrace' while no
such errors with the fix below applied.

The backtracer needs to be able to cope with non-essential invalid CFI as at
least PPC has such CFI, which is why this bug has no effect on the testsuite,
unwinder gracefully gives up on interpreting uninitialized memory.

Specifically run-backtrace.sh run has 66 warnings with this fix applied and
1514 without.


Thanks,
Jan


libdw/
2012-10-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cfi.c (execute_cfi) (enough_registers): Clear new memory after
	realloc.

diff --git a/libdw/cfi.c b/libdw/cfi.c
index f59f17d..48745ca 100644
--- a/libdw/cfi.c
+++ b/libdw/cfi.c
@@ -89,8 +89,11 @@ execute_cfi (Dwarf_CFI *cache,
 	    }
 	  else
 	    {
-	      bigger->nregs = reg + 1;
 	      fs = bigger;
+	      /* Assume reg_unspecified == 0.  */
+	      memset (fs->regs + fs->nregs, 0,
+		      sizeof (*fs->regs) * (reg + 1 - fs->nregs));
+	      fs->nregs = reg + 1;
 	    }
 	}
       return true;

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