This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libbacktrace patch committed (Was: Re: [jit] Update TODO.rst)


On Thu, Oct 17, 2013 at 8:54 PM, David Malcolm <dmalcolm@redhat.com> wrote:
>
> +* segfault seen in libbacktrace, when an ICE occurs

That reminded me to commit this libbacktrace patch I worked up a
couple of weeks ago.  Previously if some debug section was missing,
the code could compute the wrong min_offset.  The missing section
would have a zero offset, so min_offset would be set to zero, and
would then be set to the offset of the next section, even though that
one might not be the minimum.  That could lead to a segfault in some
cases, though I don't know if that is the issue that David is seeing.

Anyhow, bootstrapped and ran libbacktrace tests.  Committed to
mainline.

Ian


2013-10-17  Ian Lance Taylor  <iant@google.com>

	* elf.c (elf_add): Don't get the wrong offsets if a debug section
	is missing.
Index: elf.c
===================================================================
--- elf.c	(revision 203809)
+++ elf.c	(working copy)
@@ -759,6 +759,8 @@ elf_add (struct backtrace_state *state,
     {
       off_t end;
 
+      if (sections[i].size == 0)
+	continue;
       if (min_offset == 0 || sections[i].offset < min_offset)
 	min_offset = sections[i].offset;
       end = sections[i].offset + sections[i].size;
@@ -785,8 +787,13 @@ elf_add (struct backtrace_state *state,
   descriptor = -1;
 
   for (i = 0; i < (int) DEBUG_MAX; ++i)
-    sections[i].data = ((const unsigned char *) debug_view.data
-			+ (sections[i].offset - min_offset));
+    {
+      if (sections[i].size == 0)
+	sections[i].data = NULL;
+      else
+	sections[i].data = ((const unsigned char *) debug_view.data
+			    + (sections[i].offset - min_offset));
+    }
 
   if (!backtrace_dwarf_add (state, base_address,
 			    sections[DEBUG_INFO].data,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]