Uninitialized variable "this_id" in frame.c:get_prev_frame_1.
authorJoel Brobecker <brobecker@adacore.com>
Thu, 5 Dec 2013 12:17:40 +0000 (13:17 +0100)
committerJoel Brobecker <brobecker@adacore.com>
Fri, 6 Dec 2013 04:51:15 +0000 (08:51 +0400)
With a simple Ada program where I have 3 functions, one just calling
the next, the backtrace is currently broken when GDB is compiled
at -O2:

   #0  hello.first () at hello.adb:5
   #1  0x0000000100001475 in hello.second () at hello.adb:10
   Backtrace stopped: previous frame inner to this frame (corrupt stack?)

It turns out that a recent patch deleted the assignment of variable
this_id, making it an unitialized variable:

        * frame-unwind.c (default_frame_unwind_stop_reason): Return
        UNWIND_OUTERMOST if the frame's ID is outer_frame_id.
        * frame.c (get_prev_frame_1): Remove outer_frame_id check.

The hunk in question starts with:

-  /* Check that this frame is not the outermost.  If it is, don't try
-     to unwind to the prev frame.  */
-  this_id = get_frame_id (this_frame);
-  if (frame_id_eq (this_id, outer_frame_id))

(the code was removed as redundant - but removing the assignment
was in fact not intentional).

There is no other code in this function that sets the variable.
Instead of re-adding the statement in the lone section where it is
actually used, I inlined it, and then got rid of the variable
altogether.  This way, and until we start needing this frame ID
in another location within that function, we dont' have to worry
about the variable's validity/lifetime.

gdb/ChangeLog:

        * frame.c (get_prev_frame_1): Delete variable "this_id".
        Replace its use by a call to get_frame_id.

gdb/ChangeLog
gdb/frame.c

index 7cae7876e31f1fecdc297a3943ed5c8ee9817997..a851326ba0d5626eb5de3a8390ea4123787b6b25 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-06  Joel Brobecker  <brobecker@adacore.com>
+
+       * frame.c (get_prev_frame_1): Delete variable "this_id".
+       Replace its use by a call to get_frame_id.
+
 2013-12-05  Anthony Green  <green@moxielogic.com>
 
        * moxie-tdep.c (moxie_software_single_step): New function.
index db94d98b8d357e65e22f74c03b294791bf7f1631..576c9697c1b015d044cb5953115c05587bb15c6e 100644 (file)
@@ -1719,7 +1719,6 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame)
 static struct frame_info *
 get_prev_frame_1 (struct frame_info *this_frame)
 {
-  struct frame_id this_id;
   struct gdbarch *gdbarch;
 
   gdb_assert (this_frame != NULL);
@@ -1791,7 +1790,8 @@ get_prev_frame_1 (struct frame_info *this_frame)
      See the comment at frame_id_inner for details.  */
   if (get_frame_type (this_frame) == NORMAL_FRAME
       && this_frame->next->unwind->type == NORMAL_FRAME
-      && frame_id_inner (get_frame_arch (this_frame->next), this_id,
+      && frame_id_inner (get_frame_arch (this_frame->next),
+                        get_frame_id (this_frame),
                         get_frame_id (this_frame->next)))
     {
       CORE_ADDR this_pc_in_block;
This page took 0.03169 seconds and 4 git commands to generate.