Fix GDB crash with upstream GCC due to memcpy(NULL, ...)
authorAndreas Arnez <arnez at linux dot vnet dot ibm dot com>
Wed, 13 Nov 2013 13:00:44 +0000 (14:00 +0100)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 15 Nov 2013 16:25:23 +0000 (17:25 +0100)
Similar to qsort(), the glibc version of memcpy() also declares its
arguments with __attribute__(__nonnull__(...)).  If NULL is passed
anyway, upstream GCC's new pass '-fisolate-erroneous-paths' typically
causes a trap in such cases.  I've encountered this with GDB in
chain_candidate() when trying to execute the break.exp test case.

gdb/
2013-11-13  Andreas Arnez  <arnez@linux.vnet.ibm.com>

* dwarf2loc.c (chain_candidate): Prevent invoking memcpy with
NULL.

gdb/ChangeLog
gdb/dwarf2loc.c

index 630f86b8e76d216f65e734fb8d958e633f49cffb..fec752839092eb4bc4065114f8d82d904544bcf5 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-15  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+       * dwarf2loc.c (chain_candidate): Prevent invoking memcpy with
+       NULL.
+
 2013-11-15  Tom Tromey  <tromey@redhat.com>
 
        PR c++/16117:
index 8b6eb663b62e5c42aaa94dc476871059910bdda5..2879ead5e754994be4b4c650fb4379a39dbe7e85 100644 (file)
@@ -761,8 +761,9 @@ chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp,
                                           * (length - 1));
       result->length = length;
       result->callers = result->callees = length;
-      memcpy (result->call_site, VEC_address (call_sitep, chain),
-             sizeof (*result->call_site) * length);
+      if (!VEC_empty (call_sitep, chain))
+       memcpy (result->call_site, VEC_address (call_sitep, chain),
+               sizeof (*result->call_site) * length);
       *resultp = result;
 
       if (entry_values_debug)
This page took 0.036963 seconds and 4 git commands to generate.