[compiler-rt] 26fd956 - [GWP-ASan] 32-bit test pointers, allow multi-init for test.
Mitch Phillips via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 08:20:52 PST 2019
Author: Mitch Phillips
Date: 2019-12-09T08:19:54-08:00
New Revision: 26fd95680bcf96870fbe9187aaa7e460709ce487
URL: https://github.com/llvm/llvm-project/commit/26fd95680bcf96870fbe9187aaa7e460709ce487
DIFF: https://github.com/llvm/llvm-project/commit/26fd95680bcf96870fbe9187aaa7e460709ce487.diff
LOG: [GWP-ASan] 32-bit test pointers, allow multi-init for test.
Summary:
GWP-ASan test currently fail on 32-bit platforms, as some of the pointers are
larger than `uintptr_t` on 32-bit platforms. Fix up all those instances.
Also add an uncompress varint test where the result is an underflow.
Furthermore, allow multi-init for testing. Each gtest when running
`check-gwp_asan` apparently runs in its own instance, but when integrating
these tests into Android, this behaviour isn't the same. We remove the
global multi-init check here, to allow for testing to work elsewhere, and we're
not really worried about multi-init anyway as it's part of our contract with
the allocator.
Reviewers: eugenis, vlad.tsyrklevich
Reviewed By: eugenis
Subscribers: #sanitizers, llvm-commits, pcc
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D71121
Added:
Modified:
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
compiler-rt/lib/gwp_asan/tests/compression.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
index b7a5b591223d..df454772a231 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
@@ -110,13 +110,6 @@ void GuardedPoolAllocator::init(const options::Options &Opts) {
Opts.MaxSimultaneousAllocations == 0)
return;
- // TODO(hctim): Add a death unit test for this.
- if (SingletonPtr) {
- (*SingletonPtr->Printf)(
- "GWP-ASan Error: init() has already been called.\n");
- exit(EXIT_FAILURE);
- }
-
if (Opts.SampleRate < 0) {
Opts.Printf("GWP-ASan Error: SampleRate is < 0.\n");
exit(EXIT_FAILURE);
diff --git a/compiler-rt/lib/gwp_asan/tests/compression.cpp b/compiler-rt/lib/gwp_asan/tests/compression.cpp
index e465a4f8c72e..7a5894de1251 100644
--- a/compiler-rt/lib/gwp_asan/tests/compression.cpp
+++ b/compiler-rt/lib/gwp_asan/tests/compression.cpp
@@ -52,13 +52,13 @@ TEST(GwpAsanCompressionTest, MultiByteVarInt) {
EXPECT_EQ(Compressed[1], 0x80);
EXPECT_EQ(Compressed[2], 0x01);
- Uncompressed = 0xff010ff0;
+ Uncompressed = 0x7f010ff0;
EXPECT_EQ(5u, pack(&Uncompressed, 1u, Compressed, sizeof(Compressed)));
- EXPECT_EQ(Compressed[0], 0xe0); // +0xff010ff0 => 0x1FE021FE0 in zigzag
+ EXPECT_EQ(Compressed[0], 0xe0); // +0x7f010ff0 => 0xFE021FE0 in zigzag
EXPECT_EQ(Compressed[1], 0xbf);
EXPECT_EQ(Compressed[2], 0x88);
EXPECT_EQ(Compressed[3], 0xf0);
- EXPECT_EQ(Compressed[4], 0x1f);
+ EXPECT_EQ(Compressed[4], 0x0f);
}
TEST(GwpAsanCompressionTest, CorrectDifference) {
@@ -159,12 +159,21 @@ void runPackUnpack(uintptr_t *Test, size_t NumEntries) {
}
TEST(GwpAsanCompressionTest, UncompressVarInt) {
- uint8_t Compressed[] = {0x00, 0xaa, 0xaf, 0xd0, 0xda, 0x24};
+ uint8_t Compressed[] = {0x00, 0xaa, 0xaf, 0xd0, 0xda, 0x04};
uintptr_t Uncompressed[2];
EXPECT_EQ(2u, unpack(Compressed, sizeof(Compressed), Uncompressed, 2u));
EXPECT_EQ(Uncompressed[0], 0x00u);
- EXPECT_EQ(Uncompressed[1], 0x125aa0bd5u);
+ EXPECT_EQ(Uncompressed[1], 0x25aa0bd5u);
+}
+
+TEST(GwpAsanCompressionTest, UncompressVarIntUnderflow) {
+ uint8_t Compressed[] = {0x00, 0xab, 0xaf, 0xd0, 0xda, 0x04};
+ uintptr_t Uncompressed[2];
+
+ EXPECT_EQ(2u, unpack(Compressed, sizeof(Compressed), Uncompressed, 2u));
+ EXPECT_EQ(Uncompressed[0], 0x00u);
+ EXPECT_EQ(Uncompressed[1], UINTPTR_MAX - 0x25aa0bd5u);
}
TEST(GwpAsanCompressionTest, CompressUncompressAscending) {
@@ -188,7 +197,7 @@ TEST(GwpAsanCompressionTest, CompressUncompressZigZag) {
}
TEST(GwpAsanCompressionTest, CompressUncompressVarInt) {
- uintptr_t Test[] = {0x1981561, 0x18560, 0x125ab9135, 0x1232562};
+ uintptr_t Test[] = {0x1981561, 0x18560, 0x25ab9135, 0x1232562};
runPackUnpack(Test, sizeof(Test) / sizeof(uintptr_t));
}
More information about the llvm-commits
mailing list