[compiler-rt] [compiler-rt][asan] _aligned_malloc/_aligned_free interception. (PR #82049)

David CARLIER via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 17:19:53 PST 2024


devnexen wrote:

> The test fails for me with the latest version: (I built the check-compiler-rt target, didn't really look at the code yet)
> 
> ```
> ********************
> Testing:  0.. 10.. 20.. 30.. 40..
> FAIL: AddressSanitizer-x86_64-windows :: TestCases/Windows/aligned_mallocs.cpp (621 of 2773)
> ******************** TEST 'AddressSanitizer-x86_64-windows :: TestCases/Windows/aligned_mallocs.cpp' FAILED ********************
> Exit Code: 1
> 
> Command Output (stdout):
> --
> # RUN: at line 1
> C:/src/llvm-project/build/./bin/clang-cl.exe  -fsanitize=address -Wno-deprecated-declarations -WX -D_HAS_EXCEPTIONS=0 -gline-tables-only -gcodeview -gcolumn-info      -Od C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp -FeC:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp
> # executed command: C:/src/llvm-project/build/./bin/clang-cl.exe -fsanitize=address -Wno-deprecated-declarations -WX -D_HAS_EXCEPTIONS=0 -gline-tables-only -gcodeview -gcolumn-info -Od 'C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp' '-FeC:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp'
> # RUN: at line 2
> not  C:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp 2>&1 | FileCheck C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp
> # executed command: not 'C:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp'
> # executed command: FileCheck 'C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp'
> # .---command stderr------------
> # | C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp:43:12: error: CHECK: expected string not found in input
> # |  // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
> # |            ^
> # | <stdin>:1:1: note: scanning from here
> # | =================================================================
> # | ^
> # | <stdin>:2:12: note: possible intended match here
> # | ==14208==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000000000014 in thread T0
> # |            ^
> # |
> # | Input file: <stdin>
> # | Check file: C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp
> # |
> # | -dump-input=help explains the following input dump.
> # |
> # | Input was:
> # | <<<<<<
> # |             1: =================================================================
> # | check:43'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
> # |             2: ==14208==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x000000000014 in thread T0
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # | check:43'1                ?                                                                                                         possible intended match
> # |             3:  #0 0x7ffdf8627146 in free C:\src\llvm-project\compiler-rt\lib\asan\asan_malloc_win.cpp:71
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # |             4:  #1 0x7ff637182643 in free C:\src\llvm-project\compiler-rt\lib\asan\asan_malloc_win_thunk.cpp:52
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # |             5:  #2 0x7ff6371939dd in _aligned_free_base minkernel\crts\ucrt\src\appcrt\heap\align.cpp:530
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # |             6:  #3 0x7ff6371939dd in _aligned_free minkernel\crts\ucrt\src\appcrt\heap\align.cpp:543
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # |             7:  #4 0x7ff637181266 in main C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp:37:3
> # | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> # |             .
> # |             .
> # |             .
> # | >>>>>>
> # `-----------------------------
> # error: command failed with exit status: 1
> 
> --
> ```

Locally now I have this output (did check-compiler-rt but check-asan is faster)

![image](https://github.com/user-attachments/assets/662b683c-0dd0-487e-83ec-2b8f40161ba3)



https://github.com/llvm/llvm-project/pull/82049


More information about the llvm-commits mailing list