[PATCH] D35265: [libunwind] Handle .ARM.exidx tables without sentinel last entry

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 02:20:19 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL308871: [libunwind] Handle .ARM.exidx tables without sentinel last entry (authored by chill).

Changed prior to commit:
  https://reviews.llvm.org/D35265?vs=107311&id=107868#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35265

Files:
  libunwind/trunk/src/UnwindCursor.hpp


Index: libunwind/trunk/src/UnwindCursor.hpp
===================================================================
--- libunwind/trunk/src/UnwindCursor.hpp
+++ libunwind/trunk/src/UnwindCursor.hpp
@@ -744,14 +744,21 @@
       EHABISectionIterator<A>::begin(_addressSpace, sects);
   EHABISectionIterator<A> end =
       EHABISectionIterator<A>::end(_addressSpace, sects);
+  if (begin == end)
+    return false;
 
   EHABISectionIterator<A> itNextPC = std::upper_bound(begin, end, pc);
-  if (itNextPC == begin || itNextPC == end)
+  if (itNextPC == begin)
     return false;
   EHABISectionIterator<A> itThisPC = itNextPC - 1;
 
   pint_t thisPC = itThisPC.functionAddress();
-  pint_t nextPC = itNextPC.functionAddress();
+  // If an exception is thrown from a function, corresponding to the last entry
+  // in the table, we don't really know the function extent and have to choose a
+  // value for nextPC. Choosing max() will allow the range check during trace to
+  // succeed.
+  pint_t nextPC = (itNextPC == end) ? std::numeric_limits<pint_t>::max()
+                                    : itNextPC.functionAddress();
   pint_t indexDataAddr = itThisPC.dataAddress();
 
   if (indexDataAddr == 0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35265.107868.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/b804fc37/attachment.bin>


More information about the llvm-commits mailing list