Skip to content

Conversation

@ndrewh
Copy link
Contributor

@ndrewh ndrewh commented Nov 14, 2025

This test uses ulimit -f 1 to test what libFuzzer does when trying to create a file > 1KB. However, the none of the input files used by this test are actually >= 1KB, so there's no reason to expect this test to pass.

This test appears to be passing on accident since the "control file" happens to be > 1KB, but this is not always the case depending upon the length of the path where the test is run from.

This modifies the test to ensure that one of the input file is actually >1KB.

@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Andrew Haberlandt (ndrewh)

Changes

This test uses ulimit -f 1 to test what libFuzzer does when trying to create a file > 1KB. However, the none of the input files used by this test are actually >= 1KB, so there's no reason to expect this test to pass.

This test appears to be passing on accident since the "control file" happens to be > 1KB, but this is not always the case depending upon the length of the path where the test is run from.

This modifies the test to ensure that one of the input file is actually >1KB.


Full diff: https://github.com/llvm/llvm-project/pull/168137.diff

1 Files Affected:

  • (modified) compiler-rt/test/fuzzer/merge-posix.test (+1-1)
diff --git a/compiler-rt/test/fuzzer/merge-posix.test b/compiler-rt/test/fuzzer/merge-posix.test
index 2721668fb9706..edd91324e5a92 100644
--- a/compiler-rt/test/fuzzer/merge-posix.test
+++ b/compiler-rt/test/fuzzer/merge-posix.test
@@ -14,7 +14,7 @@ RUN: echo ....U. > %tmp/T2/2
 RUN: echo ...Z.. > %tmp/T2/3
 RUN: echo ...Z.. > %tmp/T2/4
 RUN: echo ....E. > %tmp/T2/5
-RUN: echo .....R > %tmp/T2/6
+RUN: (echo .....R; for i in {1..1024}; do echo -n X; done) > %tmp/T2/6
 
 # Check that we can report an error if file size exceeded
 RUN: (ulimit -f 1; not %run %t-FullCoverageSetTest -merge=1 %tmp/T1 %tmp/T2 2>&1 | FileCheck %s --check-prefix=SIGXFSZ)

@DanBlackwell
Copy link
Contributor

@cmtice I remember you were doing some work regarding using the 'internal shell' (#160728); does that work with the syntax used in this change?

RUN: echo ...Z.. > %tmp/T2/4
RUN: echo ....E. > %tmp/T2/5
RUN: echo .....R > %tmp/T2/6
RUN: (echo .....R; for i in {1..1024}; do echo -n X; done) > %tmp/T2/6
Copy link
Contributor Author

@ndrewh ndrewh Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, before I made this change I did look and found other tests doing similar shell scripting

I'm definitely not sure that this is the best / most portable way to write out a 1024B file 😄. We could just call into python3 (other tests do that), or use dd (but i didn't see any other tests doing that).

Copy link
Contributor Author

@ndrewh ndrewh Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another option:

RUN: %python -c "f = open('%tmp/T2/6', 'wb'); f.write(b'.....R'.ljust(1025, b'X')); f.close()"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal shell supports redirects, so this would do I believe:

RUN: %python -c "print('X' * 1024, end='')" > %tmp/T2/6

Copy link
Contributor

@DanBlackwell DanBlackwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update looks good, thanks!

@ndrewh ndrewh merged commit c4be17a into llvm:main Nov 17, 2025
10 checks passed
@boomanaiden154
Copy link
Contributor

I remember you were doing some work regarding using the 'internal shell' (#160728); does that work with the syntax used in this change?

Yes, it will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants