[compiler-rt] 5cfbfa0 - [sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
Kristina Bessonova via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 03:01:57 PDT 2022
Author: Kristina Bessonova
Date: 2022-06-16T11:59:58+02:00
New Revision: 5cfbfa035fc18b0c94dcae62d1a643269af17219
URL: https://github.com/llvm/llvm-project/commit/5cfbfa035fc18b0c94dcae62d1a643269af17219
DIFF: https://github.com/llvm/llvm-project/commit/5cfbfa035fc18b0c94dcae62d1a643269af17219.diff
LOG: [sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
This test was failing with the following error message if to run the test binary
directly, w/o using lit:
$ Sanitizer-x86_64-Test --gtest_filter=SanitizerCommon.ChainedOriginDepot*
...
[ RUN ] SanitizerCommon.ChainedOriginDepotStats
compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp:77: Failure
Expected: (stats1.allocated) > (stats0.allocated), actual: 196608 vs 196608
[ FAILED ] SanitizerCommon.ChainedOriginDepotStats (867 ms)
Since the ChainedOriginDepot* tests are not doing any cleanup, by the time
SanitizerCommon.ChainedOriginDepotStats test starts executing the depot
may not be empty, so there will be no allocation for the test.
This patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory when requested. This makes sure underlying TwoLevelMap initiates
the expected allocation during the test.
Reviewed By: eugenis
Differential Revision: https://reviews.llvm.org/D127621
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
index 472b83d63a08a..e0e2bd01069f2 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
@@ -143,4 +143,6 @@ void ChainedOriginDepot::LockAll() { depot.LockAll(); }
void ChainedOriginDepot::UnlockAll() { depot.UnlockAll(); }
+void ChainedOriginDepot::TestOnlyUnmap() { depot.TestOnlyUnmap(); }
+
} // namespace __sanitizer
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
index 2e800964a45dd..f9f192b685719 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
@@ -34,6 +34,7 @@ class ChainedOriginDepot {
void LockAll();
void UnlockAll();
+ void TestOnlyUnmap();
private:
ChainedOriginDepot(const ChainedOriginDepot &) = delete;
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
index 8e3021f613778..a557c4645ba0c 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
@@ -68,6 +68,7 @@ TEST(SanitizerCommon, ChainedOriginDepotDifferent) {
}
TEST(SanitizerCommon, ChainedOriginDepotStats) {
+ chainedOriginDepot.TestOnlyUnmap();
StackDepotStats stats0 = chainedOriginDepot.GetStats();
u32 new_id;
More information about the llvm-commits
mailing list