This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[RFC] DW_CFA_restore handling causes memory fault


Hello,

The current handling of DW_CFA_restore in dwarf2-frame.c doesn't check
if the value it tries to restore has actually been allocated. This
produces strange results (from undeterministic behavour to a GDB crash).
The attached patch tries to fix that by following the GCC 'convention'
that an unspecified register implies "same value".

It's debatable wether the compiler is right to produce DW_CFA_restore
without specifying all the registers initial state in the CIE, but
that's another story, isn't it ?

Regards,
Fred.
2005-11-17  FrÃdÃric Riss  <frederic.riss@st.com>
        
                * dwarf2-frame.c: (execute_cfa_program): Don't access 
		past the allocated dwarf2_frame_state.initial.regs.


Index: dwarf2-frame.c
===================================================================
--- dwarf2-frame.c	(revision 98)
+++ dwarf2-frame.c	(working copy)
@@ -294,7 +294,10 @@
 	  gdb_assert (fs->initial.reg);
 	  reg = insn & 0x3f;
 	  dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
-	  fs->regs.reg[reg] = fs->initial.reg[reg];
+	  if (reg < fs->initial.num_regs)
+	      fs->regs.reg[reg] = fs->initial.reg[reg];
+	  else 
+	      fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED;
 	}
       else
 	{

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