Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] DW_CFA_restore handling causes memory fault
@ 2005-11-17 18:58 Frederic RISS
  2005-11-17 19:46 ` Jim Blandy
  0 siblings, 1 reply; 16+ messages in thread
From: Frederic RISS @ 2005-11-17 18:58 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]

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.

[-- Attachment #2: dwarf2.patch --]
[-- Type: text/x-patch, Size: 707 bytes --]

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
 	{

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-11-28  8:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-17 18:58 [RFC] DW_CFA_restore handling causes memory fault Frederic RISS
2005-11-17 19:46 ` Jim Blandy
2005-11-18 12:12   ` Frederic RISS
2005-11-18 12:32     ` Jim Blandy
2005-11-18 13:30       ` Frederic RISS
2005-11-18 14:21         ` Mark Kettenis
2005-11-18 15:55           ` Frederic RISS
2005-11-23 16:51           ` Frederic RISS
2005-11-25 10:32             ` Mark Kettenis
2005-11-25 14:31               ` Frederic RISS
2005-11-25 18:35                 ` Daniel Jacobowitz
2005-11-25 23:00                 ` Mark Kettenis
2005-11-25 23:21                   ` Joel Brobecker
2005-11-28 19:30                     ` Frederic RISS
2005-11-18 14:43         ` Eli Zaretskii
2005-11-18 15:08           ` Frederic RISS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox