From: Andreas Arnez Date: Wed, 13 Nov 2013 13:00:44 +0000 (+0100) Subject: Fix GDB crash with upstream GCC due to memcpy(NULL, ...) X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=19a1b230f33dbcfa54cd1a9f88c2d5158f833f6f;p=deliverable%2Fbinutils-gdb.git Fix GDB crash with upstream GCC due to memcpy(NULL, ...) 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 * dwarf2loc.c (chain_candidate): Prevent invoking memcpy with NULL. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 630f86b8e7..fec7528390 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2013-11-15 Andreas Arnez + + * dwarf2loc.c (chain_candidate): Prevent invoking memcpy with + NULL. + 2013-11-15 Tom Tromey PR c++/16117: diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 8b6eb663b6..2879ead5e7 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -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)