summaryrefslogtreecommitdiff
path: root/lib/ubsan/ubsan_type_hash.h
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-06-02 18:36:12 +0000
committerIvan Krasin <krasin@chromium.org>2016-06-02 18:36:12 +0000
commit4deefb03523c51ca2eba3fabff692a47f24e1bfa (patch)
treee50a8e561e9ffb94226b6a69ab4cfa88b63b0bb3 /lib/ubsan/ubsan_type_hash.h
parente151fbe8a11f85f4b0577ab3d27ef5254c3c4f74 (diff)
UBSan: crash less often on corrupted Vtables.
Summary: This CL adds a weak check for a Vtable prefix: for a well-formed Vtable, we require the prefix to be within [-1<<20; 1<<20]. Practically, this solves most of the known cases when UBSan segfaults without providing any useful diagnostics. Reviewers: pcc Subscribers: kubabrecka Differential Revision: http://reviews.llvm.org/D19750 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan/ubsan_type_hash.h')
-rw-r--r--lib/ubsan/ubsan_type_hash.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/ubsan/ubsan_type_hash.h b/lib/ubsan/ubsan_type_hash.h
index 695fed905..aa638713f 100644
--- a/lib/ubsan/ubsan_type_hash.h
+++ b/lib/ubsan/ubsan_type_hash.h
@@ -53,6 +53,10 @@ bool checkDynamicType(void *Object, void *Type, HashValue Hash);
const unsigned VptrTypeCacheSize = 128;
+/// A sanity check for Vtable. Offsets to top must be reasonably small
+/// numbers (by absolute value). It's a weak check for Vtable corruption.
+const int VptrMaxOffsetToTop = 1<<20;
+
/// \brief A cache of the results of checkDynamicType. \c checkDynamicType would
/// return \c true (modulo hash collisions) if
/// \code