[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

GitOrigin-RevId: 26fd95680bcf96870fbe9187aaa7e460709ce487
diff --git a/guarded_pool_allocator.cpp b/guarded_pool_allocator.cpp
index b7a5b59..df45477 100644
--- a/guarded_pool_allocator.cpp
+++ b/guarded_pool_allocator.cpp
@@ -110,13 +110,6 @@
       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/tests/compression.cpp b/tests/compression.cpp
index e465a4f..7a5894d 100644
--- a/tests/compression.cpp
+++ b/tests/compression.cpp
@@ -52,13 +52,13 @@
   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 @@
 }
 
 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, CompressUncompressVarInt) {
-  uintptr_t Test[] = {0x1981561, 0x18560, 0x125ab9135, 0x1232562};
+  uintptr_t Test[] = {0x1981561, 0x18560, 0x25ab9135, 0x1232562};
   runPackUnpack(Test, sizeof(Test) / sizeof(uintptr_t));
 }