This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
ClosedPublic

Authored by krisb on Jun 13 2022, 2:28 AM.

Details

Summary

This test was failing with the following error message (at least on X86 Linux,
but I believe other targets should be affected as well):

$ 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)

This happens iff to run the test binary directly, w/o using lit.
lit seems to run tests one by one, so they cannot affect each other.
But for cross-compilation & remote test execution using lit might not be convenient.
So, having the tests passed natively is still the case.

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.

Following example of compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp,
this patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory where requested. This makes sure underlying TwoLevelMap initiates
the expected allocation.

Diff Detail

Event Timeline

krisb created this revision.Jun 13 2022, 2:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 2:28 AM
krisb requested review of this revision.Jun 13 2022, 2:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2022, 2:28 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
krisb edited the summary of this revision. (Show Details)Jun 13 2022, 1:37 PM
eugenis accepted this revision.Jun 14 2022, 3:19 PM

LGTM

This revision is now accepted and ready to land.Jun 14 2022, 3:19 PM
This revision was landed with ongoing or failed builds.Jun 16 2022, 3:01 AM
This revision was automatically updated to reflect the committed changes.