[compiler-rt] 33e3554 - Change __lsan::kMaxAllowedMallocSize literal types to unsigned long long
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 7 10:38:22 PST 2021
Author: Clemens Wasser
Date: 2021-12-07T10:38:13-08:00
New Revision: 33e3554ea33d98f476f5d5a6fb85472d5dccfe18
URL: https://github.com/llvm/llvm-project/commit/33e3554ea33d98f476f5d5a6fb85472d5dccfe18
DIFF: https://github.com/llvm/llvm-project/commit/33e3554ea33d98f476f5d5a6fb85472d5dccfe18.diff
LOG: Change __lsan::kMaxAllowedMallocSize literal types to unsigned long long
It is required for the [Leak Sanitizer port to Windows](https://reviews.llvm.org/D115103).
The currently used `unsigned long` type is 64 bits wide on UNIX like systems but only 32 bits wide on Windows.
Because of that, the literal `8UL << 30` causes an integer overflow on Windows.
By changing the type of the literals to `unsigned long long`, we have consistent behavior and no overflows on all Platforms.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D115186
Added:
Modified:
compiler-rt/lib/lsan/lsan_allocator.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/lsan/lsan_allocator.cpp b/compiler-rt/lib/lsan/lsan_allocator.cpp
index 9af7bbbb01ec0..ea4c6c9cf6470 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.cpp
+++ b/compiler-rt/lib/lsan/lsan_allocator.cpp
@@ -27,11 +27,11 @@ extern "C" void *memset(void *ptr, int value, uptr num);
namespace __lsan {
#if defined(__i386__) || defined(__arm__)
-static const uptr kMaxAllowedMallocSize = 1UL << 30;
+static const uptr kMaxAllowedMallocSize = 1ULL << 30;
#elif defined(__mips64) || defined(__aarch64__)
-static const uptr kMaxAllowedMallocSize = 4UL << 30;
+static const uptr kMaxAllowedMallocSize = 4ULL << 30;
#else
-static const uptr kMaxAllowedMallocSize = 8UL << 30;
+static const uptr kMaxAllowedMallocSize = 8ULL << 30;
#endif
static Allocator allocator;
More information about the llvm-commits
mailing list