Skip to content

DFSAN release_shadow_space.c is flaky #91287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joker-eph opened this issue May 7, 2024 · 3 comments · Fixed by #94770
Closed

DFSAN release_shadow_space.c is flaky #91287

joker-eph opened this issue May 7, 2024 · 3 comments · Fixed by #94770

Comments

@joker-eph
Copy link
Collaborator

For a few days, I see this test being flaky on the bot, here is an example run: https://lab.llvm.org/buildbot/#/builders/272/builds/15892

******************** TEST 'DataFlowSanitizer-x86_64 :: release_shadow_space.c' FAILED ********************
Exit Code: 134
Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/./bin/clang  -fsanitize=dataflow  -m64  /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp &&  /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/./bin/clang -fsanitize=dataflow -m64 /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
RSS at start: 7982000249035, after mmap: 7982000351439, after mmap+set label: 7982000453843, after fixed map: 7982000249043, after another mmap+set label: 7982000453843, after munmap: 7982000249043
RUN: at line 2: /build/buildbot/premerge-monolithic-linux/build/./bin/clang  -fsanitize=dataflow  -m64  /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp &&  /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/./bin/clang -fsanitize=dataflow -m64 /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
RSS at start: 7982000249335, after mmap: 7982000351803, after mmap+set label: 7982000454207, after fixed map: 7982000249407, after another mmap+set label: 7982000454207, after munmap: 7982000249407
RUN: at line 3: /build/buildbot/premerge-monolithic-linux/build/./bin/clang  -fsanitize=dataflow  -m64  /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp &&  /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/./bin/clang -fsanitize=dataflow -m64 /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
RSS at start: 10468000370887, after mmap: 10468000473297, after mmap+set label: 10468000678159, after fixed map: 10468000370959, after another mmap+set label: 10468000678159, after munmap: 10468000370966
RUN: at line 4: /build/buildbot/premerge-monolithic-linux/build/./bin/clang  -fsanitize=dataflow  -m64  /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp &&  /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/./bin/clang -fsanitize=dataflow -m64 /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 -o /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
+ /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
RSS at start: 10468002893479, after mmap: 10468004446521, after mmap+set label: 11255317174414, after fixed map: 11255316867214, after another mmap+set label: 11255317174414, after munmap: 11255316945944
release_shadow_space.c.tmp: /build/buildbot/premerge-monolithic-linux/llvm-project/compiler-rt/test/dfsan/release_shadow_space.c:100: int main(int, char **): Assertion `after_fixed_mmap <= before + delta + mmap_origin_chain_kb' failed.
/build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.script: line 4: 3921607 Aborted                 /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/compiler-rt/test/dfsan/X86_64Config/Output/release_shadow_space.c.tmp
--
********************
@joker-eph
Copy link
Collaborator Author

@MaskRay : maybe you have thoughts on this?

joker-eph added a commit to joker-eph/llvm-project that referenced this issue May 8, 2024
The current pass rate on the bot is ~50%.

llvm#91287
@MaskRay
Copy link
Member

MaskRay commented May 8, 2024

Seems fine to disable it now. I've seen it failed for unrelated patches.

joker-eph added a commit that referenced this issue May 9, 2024
The current pass rate on the bot is ~50%.

#91287
thurstond added a commit to thurstond/llvm-project that referenced this issue Jun 6, 2024
This test case shows a limitation of DFSan's sscanf implementation
(introduced in https://reviews.llvm.org/D153775): it simply ignores
ordinary characters in the format string, instead of actually comparing
them against the input. This may change the semantics of instrumented programs.

Importantly, this also means that DFSan's release_shadow_space.c test,
which relies on sscanf to scrape the RSS from /proc/maps output, will
incorrectly match lines that don't contain RSS information. As a result,
it is scraping numbers from irrelevant output (e.g., base addresses), and can
therefore result in test flakiness
(llvm#91287).
@thurstond
Copy link
Contributor

The reason for the failure is that DFSan's sscanf is ignoring ordinary characters in the format string. DFSan's release_shadow_space.c test relies on sscanf to scrape the RSS from /proc/maps output and is therefore scraping numbers from irrelevant output (e.g., base addresses), leading to test flakiness.

I've added a test case that illustrates this: #94700

thurstond added a commit that referenced this issue Jun 7, 2024
This test case shows a limitation of DFSan's sscanf implementation
(introduced in https://reviews.llvm.org/D153775): it simply ignores
ordinary characters in the format string, instead of actually comparing
them against the input. This may change the semantics of instrumented
programs.

Importantly, this also means that DFSan's release_shadow_space.c test,
which relies on sscanf to scrape the RSS from /proc/maps output, will
incorrectly match lines that don't contain RSS information. As a result,
it adding together numbers from irrelevant output (e.g., base
addresses), resulting in test flakiness
(#91287).
thurstond added a commit to thurstond/llvm-project that referenced this issue Jun 7, 2024
DFSan's sscanf is incorrect (llvm#94769), which
results in erroneous matches when scraping RSS /proc/maps. This patch works
around the issue by using strstr as a secondary check.

It also adds a loose validity check for the initial RSS, to guard
against future regressions in get_rss_kb().

Fixes llvm#91287
thurstond added a commit that referenced this issue Jun 8, 2024
DFSan's sscanf is incorrect
(#94769), which results in
erroneous matches when scraping RSS from /proc/maps. This patch works
around the issue by using strstr as a secondary check.

It also adds a loose validity check for the initial RSS measurement, to
guard against regressions in get_rss_kb().

Fixes #91287
nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this issue Jun 9, 2024
DFSan's sscanf is incorrect
(llvm#94769), which results in
erroneous matches when scraping RSS from /proc/maps. This patch works
around the issue by using strstr as a secondary check.

It also adds a loose validity check for the initial RSS measurement, to
guard against regressions in get_rss_kb().

Fixes llvm#91287

Signed-off-by: Hafidz Muzakky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants