[llvm] r303946 - [llvm-pdbdump] Don't crash when displaying padding.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 17:15:15 PDT 2017


Author: zturner
Date: Thu May 25 19:15:15 2017
New Revision: 303946

URL: http://llvm.org/viewvc/llvm-project?rev=303946&view=rev
Log:
[llvm-pdbdump] Don't crash when displaying padding.

We have a lot of complicated logic to determine where padding
is in a record, and the debug info doesn't always provide enough
information to figure it out with laser precision.  In this case
we were putting the padding in the wrong place causing an
out of bounds access on a BitVector.

Right now we decide that any trailing padding of a child type
will be truncated during record layout, but this is only true
insofar as the class still is sized properly to end on an
alignment boundary, which the algorithm doesn't yet know about.

For now, just don't crash, even though we display padding twice
in this case.

Modified:
    llvm/trunk/tools/llvm-pdbdump/PrettyClassLayoutGraphicalDumper.cpp

Modified: llvm/trunk/tools/llvm-pdbdump/PrettyClassLayoutGraphicalDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/PrettyClassLayoutGraphicalDumper.cpp?rev=303946&r1=303945&r2=303946&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/PrettyClassLayoutGraphicalDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/PrettyClassLayoutGraphicalDumper.cpp Thu May 25 19:15:15 2017
@@ -80,7 +80,8 @@ bool PrettyClassLayoutGraphicalDumper::s
 
     if (Item->getLayoutSize() > 0) {
       uint32_t Prev = RelativeOffset + Item->getLayoutSize() - 1;
-      NextPaddingByte = UseMap.find_next_unset(Prev);
+      if (Prev < UseMap.size())
+        NextPaddingByte = UseMap.find_next_unset(Prev);
     }
   }
 




More information about the llvm-commits mailing list