[commit] Fix ia64 segfault

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] Fix ia64 segfault

Daniel Jacobowitz-2
This bug was my fault, from the introduction of target_read_alloc.
ktab_size is a size_t, and thus unsigned; it was being assigned (LONGEST)-1
and then tested.  Eventually this led to a NULL dereference.

Tested on ia64-linux and committed.

Just a reminder: the best thing you can do for any GDB port is test it
regularly!  Until recently I had no convenient system on which I could test
ia64-linux GDB.  I do now, but the results are dismal even after this patch.
powerpc64-linux is in pretty awful shape too.

--
Daniel Jacobowitz
CodeSourcery

2006-12-28  Daniel Jacobowitz  <[hidden email]>

        * ia64-tdep.c (get_kernel_table): Correct signedness in check
        for a negative return value.

Index: gdb/ia64-tdep.c
===================================================================
RCS file: /scratch/gcc/repos/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.140
diff -u -p -r1.140 ia64-tdep.c
--- gdb/ia64-tdep.c 12 Jul 2006 18:13:45 -0000 1.140
+++ gdb/ia64-tdep.c 28 Dec 2006 20:24:25 -0000
@@ -2486,13 +2487,14 @@ get_kernel_table (unw_word_t ip, unw_dyn
   if (!ktab)
     {
       gdb_byte *ktab_buf;
-      size_t size;
+      LONGEST size;
 
-      ktab_size = getunwind_table (&ktab_buf);
-      if (ktab_size <= 0)
+      size = getunwind_table (&ktab_buf);
+      if (size <= 0)
  return -UNW_ENOINFO;
-      else
- ktab = (struct ia64_table_entry *) ktab_buf;
+
+      ktab = (struct ia64_table_entry *) ktab_buf;
+      ktab_size = size;
 
       for (etab = ktab; etab->start_offset; ++etab)
         etab->info_offset += KERNEL_START;