Skip to content

[rtsan] Add basic test for c compilation #107717

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

Merged
merged 1 commit into from
Sep 7, 2024
Merged

Conversation

cjappl
Copy link
Contributor

@cjappl cjappl commented Sep 7, 2024

I was reminded of realtime-sanitizer/rtsan#25, where we were including C++ code that was never linked in C.

Adding this test to ensure that we don't break this functionality in the future

@cjappl
Copy link
Contributor Author

cjappl commented Sep 7, 2024

CC @davidtrevelyan

@cjappl cjappl merged commit 3d0f44f into llvm:main Sep 7, 2024
8 of 10 checks passed
@cjappl cjappl deleted the add_basic_c_test branch September 7, 2024 20:29
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2024

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

Author: Chris Apple (cjappl)

Changes

I was reminded of realtime-sanitizer/rtsan#25, where we were including C++ code that was never linked in C.

Adding this test to ensure that we don't break this functionality in the future


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

1 Files Affected:

  • (modified) compiler-rt/test/rtsan/basic.cpp (+1)
diff --git a/compiler-rt/test/rtsan/basic.cpp b/compiler-rt/test/rtsan/basic.cpp
index c7cbfcda31562e..f4075bb27e4f91 100644
--- a/compiler-rt/test/rtsan/basic.cpp
+++ b/compiler-rt/test/rtsan/basic.cpp
@@ -1,4 +1,5 @@
 // RUN: %clangxx -fsanitize=realtime %s -o %t
+// RUN: %clang -fsanitize=realtime %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 // UNSUPPORTED: ios
 

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 7, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-qemu running on sanitizer-buildbot3 while building compiler-rt at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/139/builds/3439

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
[303/308] Generating ../../bin/llvm-strip
[304/308] Generating ../../bin/llvm-readelf
[305/308] Linking CXX executable bin/llvm-nm
[306/308] Linking CXX executable bin/sancov
[307/308] Linking CXX executable bin/llvm-objdump
[307/308] Running the HWAddressSanitizer tests with Intel LAM
llvm-lit: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/lit.common.cfg.py:367: warning: %device_rm is not implemented
llvm-lit: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 108 of 109 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50
FAIL: HWAddressSanitizer-x86_64 :: TestCases/Posix/ignore_free_hook.cpp (59 of 108)
******************** TEST 'HWAddressSanitizer-x86_64 :: TestCases/Posix/ignore_free_hook.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/./bin/clang  --driver-mode=g++  -m64  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -O2 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -o /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp -DTEST=basic_hook_works && not env SSH_CONTROL_SOCKET=/home/b/sanitizer-x86_64-linux-qemu/build/qemu_tmp/ssh-control-socket /home/b/sanitizer-x86_64-linux-qemu/sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/ssh_run.sh /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp    2>&1 | FileCheck /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -check-prefix=CHECK-BASIC
+ /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/./bin/clang --driver-mode=g++ -m64 -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -O2 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -o /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp -DTEST=basic_hook_works
+ not env SSH_CONTROL_SOCKET=/home/b/sanitizer-x86_64-linux-qemu/build/qemu_tmp/ssh-control-socket /home/b/sanitizer-x86_64-linux-qemu/sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/ssh_run.sh /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -check-prefix=CHECK-BASIC
/home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp:44:18: error: CHECK-BASIC: expected string not found in input
 // CHECK-BASIC: Free Respected
                 ^
<stdin>:1:1: note: scanning from here
HWAddressSanitizer:DEADLYSIGNAL
^
<stdin>:4:71: note: possible intended match here
==715==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
                                                                      ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: HWAddressSanitizer:DEADLYSIGNAL 
check:44'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: ==715==ERROR: HWAddressSanitizer: SEGV on unknown address (pc 0x55b8c2b6efd9 bp 0x7ffe07afda40 sp 0x7ffe07afd988 T715) 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            3: ==715==The signal is caused by a READ memory access. 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: ==715==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used. 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:44'1                                                                           ?                                                                                                 possible intended match
            5:  #0 0x55b8c2b6efd9 in __hwasan_store8 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/lib/hwasan/hwasan.cpp:598:3 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #1 0x55b8c2bba004 in allocate /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp:38:28 
Step 30 (test hwasan x86_64_lam_qemu) failure: test hwasan x86_64_lam_qemu (failure)
...
[303/308] Generating ../../bin/llvm-strip
[304/308] Generating ../../bin/llvm-readelf
[305/308] Linking CXX executable bin/llvm-nm
[306/308] Linking CXX executable bin/sancov
[307/308] Linking CXX executable bin/llvm-objdump
[307/308] Running the HWAddressSanitizer tests with Intel LAM
llvm-lit: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/lit.common.cfg.py:367: warning: %device_rm is not implemented
llvm-lit: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 108 of 109 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50
FAIL: HWAddressSanitizer-x86_64 :: TestCases/Posix/ignore_free_hook.cpp (59 of 108)
******************** TEST 'HWAddressSanitizer-x86_64 :: TestCases/Posix/ignore_free_hook.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/./bin/clang  --driver-mode=g++  -m64  -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -O2 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -o /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp -DTEST=basic_hook_works && not env SSH_CONTROL_SOCKET=/home/b/sanitizer-x86_64-linux-qemu/build/qemu_tmp/ssh-control-socket /home/b/sanitizer-x86_64-linux-qemu/sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/ssh_run.sh /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp    2>&1 | FileCheck /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -check-prefix=CHECK-BASIC
+ /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/./bin/clang --driver-mode=g++ -m64 -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -O2 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -o /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp -DTEST=basic_hook_works
+ not env SSH_CONTROL_SOCKET=/home/b/sanitizer-x86_64-linux-qemu/build/qemu_tmp/ssh-control-socket /home/b/sanitizer-x86_64-linux-qemu/sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/ssh_run.sh /home/b/sanitizer-x86_64-linux-qemu/build/llvm_build2_x86_64_lam_qemu/projects/compiler-rt/test/hwasan/X86_64/TestCases/Posix/Output/ignore_free_hook.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp -check-prefix=CHECK-BASIC
/home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp:44:18: error: CHECK-BASIC: expected string not found in input
 // CHECK-BASIC: Free Respected
                 ^
<stdin>:1:1: note: scanning from here
HWAddressSanitizer:DEADLYSIGNAL
^
<stdin>:4:71: note: possible intended match here
==715==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used.
                                                                      ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: HWAddressSanitizer:DEADLYSIGNAL 
check:44'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: ==715==ERROR: HWAddressSanitizer: SEGV on unknown address (pc 0x55b8c2b6efd9 bp 0x7ffe07afda40 sp 0x7ffe07afd988 T715) 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            3: ==715==The signal is caused by a READ memory access. 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: ==715==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used. 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:44'1                                                                           ?                                                                                                 possible intended match
            5:  #0 0x55b8c2b6efd9 in __hwasan_store8 /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/lib/hwasan/hwasan.cpp:598:3 
check:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            6:  #1 0x55b8c2bba004 in allocate /home/b/sanitizer-x86_64-linux-qemu/build/llvm-project/compiler-rt/test/hwasan/TestCases/Posix/ignore_free_hook.cpp:38:28 

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.

3 participants