Skip to content

sanitizer_common: add unsupported test for free_sized and free_aligned_sized from C23 #144727

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
Jun 18, 2025

Conversation

jcking
Copy link
Contributor

@jcking jcking commented Jun 18, 2025

For #144435

@llvmbot
Copy link
Member

llvmbot commented Jun 18, 2025

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

Author: Justin King (jcking)

Changes

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

2 Files Affected:

  • (added) compiler-rt/test/sanitizer_common/TestCases/Linux/free_aligned_sized.c (+13)
  • (added) compiler-rt/test/sanitizer_common/TestCases/Linux/free_sized.c (+15)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/free_aligned_sized.c b/compiler-rt/test/sanitizer_common/TestCases/Linux/free_aligned_sized.c
new file mode 100644
index 0000000000000..27cc8752f2841
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/free_aligned_sized.c
@@ -0,0 +1,13 @@
+// RUN: %clang -std=c23 -O0 %s -o %t && %run %t
+// UNSUPPORTED: asan, hwasan, rtsan, tsan, msan, lsan, ubsan
+
+#include <stddef.h>
+#include <stdlib.h>
+
+extern void free_aligned_sized(void* p, size_t alignment, size_t size);
+
+int main() {
+  volatile void *p = aligned_alloc(128, 1024);
+  free_aligned_sized((void*)p, 128, 1024);
+  return 0;
+}
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/free_sized.c b/compiler-rt/test/sanitizer_common/TestCases/Linux/free_sized.c
new file mode 100644
index 0000000000000..b3a469b838694
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/free_sized.c
@@ -0,0 +1,15 @@
+// RUN: %clang -std=c23 -O0 %s -o %t && %run %t
+// UNSUPPORTED: asan, hwasan, rtsan, tsan, msan, lsan, ubsan
+
+#include <stddef.h>
+#include <stdlib.h>
+
+extern void *aligned_alloc(size_t alignment, size_t size);
+
+extern void free_sized(void* p, size_t size);
+
+int main() {
+  volatile void *p = malloc(64);
+  free_sized((void*)p, 64);
+  return 0;
+}

Copy link

github-actions bot commented Jun 18, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@jcking jcking force-pushed the sanitizer_common_free_aligned_sized branch from 1c55a82 to 0688a6c Compare June 18, 2025 16:31
@vitalybuka vitalybuka merged commit d9f7979 into llvm:main Jun 18, 2025
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 18, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building compiler-rt at step 5 "compile-openmp".

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

Here is the relevant piece of the build log for the reference
Step 5 (compile-openmp) failure: build (failure)
...
0.130 [410/130/147] Building CXX object libc/src/__support/RPC/CMakeFiles/libc.src.__support.RPC.rpc_client.dir/rpc_client.cpp.o
0.131 [409/130/148] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.getenv.dir/getenv.cpp.o
0.131 [408/130/149] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.abs.dir/abs.cpp.o
0.132 [407/130/150] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.labs.dir/labs.cpp.o
0.132 [406/130/151] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.llabs.dir/llabs.cpp.o
0.132 [405/130/152] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.rand_util.dir/rand_util.cpp.o
0.133 [404/130/153] Building CXX object libc/src/stdlib/CMakeFiles/libc.src.stdlib.srand.dir/srand.cpp.o
0.133 [403/130/154] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strncmp.dir/strncmp.cpp.o
0.134 [402/130/155] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strncpy.dir/strncpy.cpp.o
0.134 [401/130/156] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.o
FAILED: libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.o 
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang++ --target=amdgcn-amd-amdhsa -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -D__LIBC_USE_FLOAT16_CONVERSION -I/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc -isystem /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa -O3 -DNDEBUG --target=amdgcn-amd-amdhsa -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES | LIBC_MATH_NO_ERRNO | LIBC_MATH_NO_EXCEPT)" -fpie -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -nogpulib -fvisibility=hidden -fconvergent-functions -flto -Wno-multi-gpu -Xclang -mcode-object-version=none -DLIBC_COPT_PUBLIC_PACKAGING -UNDEBUG -fno-builtin-strstr -MD -MT libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.o -MF libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.o.d -o libc/src/string/CMakeFiles/libc.src.string.strstr.dir/strstr.cpp.o -c /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/strstr.cpp
In file included from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/strstr.cpp:14:
In file included from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/memory_utils/inline_strstr.h:15:
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/string_utils.h:66:27: error: unknown type name 'uintptr_t'
   66 |   for (; reinterpret_cast<uintptr_t>(char_ptr) % sizeof(Word) != 0;
      |                           ^
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/string_utils.h:66:48: error: invalid operands to binary expression ('const char *' and 'unsigned long')
   66 |   for (; reinterpret_cast<uintptr_t>(char_ptr) % sizeof(Word) != 0;
      |                                      ~~~~~~~~  ^ ~~~~~~~~~~~~
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/string_utils.h:107:27: error: unknown type name 'uintptr_t'
  107 |   for (; reinterpret_cast<uintptr_t>(char_ptr) % sizeof(Word) != 0 && cur < n;
      |                           ^
/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/src/string/string_utils.h:107:48: error: invalid operands to binary expression ('const unsigned char *' and 'unsigned long')
  107 |   for (; reinterpret_cast<uintptr_t>(char_ptr) % sizeof(Word) != 0 && cur < n;
      |                                      ~~~~~~~~  ^ ~~~~~~~~~~~~
4 errors generated.
0.134 [401/129/157] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.strcasecmp.dir/strcasecmp.cpp.o
0.134 [401/128/158] Generating header assert.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/assert.yaml
0.134 [401/127/159] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.strncasecmp.dir/strncasecmp.cpp.o
0.134 [401/126/160] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/string.h
0.134 [401/125/161] Generating header string.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/string.yaml
0.134 [401/124/162] Generating header strings.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/strings.yaml
0.134 [401/123/163] Generating header fenv.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/fenv.yaml
0.134 [401/122/164] Generating header inttypes.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/inttypes.yaml
0.134 [401/121/165] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/inttypes.h
0.134 [401/120/166] Generating header wchar.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/wchar.yaml
0.134 [401/119/167] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/wchar.h
0.134 [401/118/168] Generating header ctype.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/ctype.yaml
0.134 [401/117/169] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/ctype.h
0.134 [401/116/170] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/stdlib.h
0.134 [401/115/171] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/locale.h
0.135 [401/114/172] Generating header locale.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/locale.yaml
0.135 [401/113/173] Generating header uchar.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/uchar.yaml
0.135 [401/112/174] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/uchar.h
0.135 [401/111/175] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/time.h
0.135 [401/110/176] Building CXX object libc/src/string/CMakeFiles/libc.src.string.strcasestr.dir/strcasestr.cpp.o
0.135 [401/109/177] Generating header time.h from /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/runtimes/../libc/include/time.yaml
0.136 [401/108/178] Generating /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/include/amdgcn-amd-amdhsa/llvm-libc-decls/signal.h

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