Skip to content

Conversation

@devnexen
Copy link
Member

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 16, 2024

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

Author: David CARLIER (devnexen)

Changes

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

2 Files Affected:

  • (modified) compiler-rt/lib/asan/asan_malloc_win.cpp (+11)
  • (modified) compiler-rt/lib/asan/asan_win_dll_thunk.cpp (+2)
diff --git a/compiler-rt/lib/asan/asan_malloc_win.cpp b/compiler-rt/lib/asan/asan_malloc_win.cpp
index 7e1d04c36dd580..01428a7c582842 100644
--- a/compiler-rt/lib/asan/asan_malloc_win.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_win.cpp
@@ -171,6 +171,17 @@ void *_recalloc_base(void *p, size_t n, size_t elem_size) {
   return _recalloc(p, n, elem_size);
 }
 
+ALLOCATION_FUNCTION_ATTRIBUTE
+void *_aligned_malloc(size_t alignment, size_t size) {
+  GET_STACK_TRACE_MALLOC;
+  return asan_aligned_alloc(alignment, size, &stack);
+}
+
+ALLOCATION_FUNCTION_ATTRIBUTE
+void *_aligned_free(void *p) {
+  free(p);
+}
+
 ALLOCATION_FUNCTION_ATTRIBUTE
 void *_expand(void *memblock, size_t size) {
   // _expand is used in realloc-like functions to resize the buffer if possible.
diff --git a/compiler-rt/lib/asan/asan_win_dll_thunk.cpp b/compiler-rt/lib/asan/asan_win_dll_thunk.cpp
index 0fa636bec0d001..fecf63e53d66e9 100644
--- a/compiler-rt/lib/asan/asan_win_dll_thunk.cpp
+++ b/compiler-rt/lib/asan/asan_win_dll_thunk.cpp
@@ -30,10 +30,12 @@
 INTERCEPT_WRAP_V_W(free)
 INTERCEPT_WRAP_V_W(_free_base)
 INTERCEPT_WRAP_V_WW(_free_dbg)
+INTERCEPT_WRAP_V_W(_aligned_free)
 
 INTERCEPT_WRAP_W_W(malloc)
 INTERCEPT_WRAP_W_W(_malloc_base)
 INTERCEPT_WRAP_W_WWWW(_malloc_dbg)
+INTERCEPT_WRAP_W_WW(_aligned_malloc)
 
 INTERCEPT_WRAP_W_WW(calloc)
 INTERCEPT_WRAP_W_WW(_calloc_base)

@github-actions
Copy link

github-actions bot commented Feb 16, 2024

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

@cjappl
Copy link
Contributor

cjappl commented Oct 22, 2024

This needs some tests

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch 2 times, most recently from 99fb735 to b44305b Compare October 22, 2024 18:13
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

return _recalloc(p, n, elem_size);
}

__declspec(noinline) void *_aligned_malloc(size_t alignment, size_t size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the first parameter be size and the second alignment?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, we need to actually intercept the system functions by adding these to ReplaceSystemMalloc().

We should also remove the

// TODO(timurrrr): Might want to add support for _aligned_* allocation
// functions to detect a bit more bugs.  Those functions seem to wrap malloc().

comment now :-)

}

__declspec(noinline) void *_aligned_realloc(void *p, size_t alignment,
size_t size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here also, I think the parameters should be p, size, alignment.

}

__declspec(noinline) void *_aligned_free(void *p) { free(p); }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Might as well do _aligned_msize while we're here?

@@ -0,0 +1,20 @@
// RUN: %clang_cl_asan %Od %s %Fe%t
Copy link
Collaborator

Choose a reason for hiding this comment

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

This basically does the same as compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cpp
But like the test you're adding, that only checks that we can call the functions and get aligned memory back. It doesn't check that we're intercepting the system's implementations.

We want a test that fails if we fail to intercept the functions, and passes otherwise. How about something like using _aligned_malloc for a 128-byte chunk of memory, trying to write to one byte before the address and checking that we get a proper asan error?

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch 2 times, most recently from 91e27d7 to a735dda Compare November 4, 2024 23:23
Copy link
Collaborator

Choose a reason for hiding this comment

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

There needs to be a FileCheck invocation on the RUN line for the CHECKs to get checked.

Also, can we update compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cpp instead of adding a new one?

aarongable pushed a commit to chromium/chromium that referenced this pull request Nov 7, 2024
When using ASAN, PartitionAlloc-Everywhere is disabled because ASAN
hooks the allocation functions instead, and needs to hear about the
allocations in order to protect them.

But ASAN does not hook the HeapAlloc() function used by the Rust
stdlib so it does not hear about heap allocations made by Rust. When
ASAN is enabled on Windows, we can redirect allocations to
_aligned_malloc and friends. ASAN is being taught to hook those
functions unconditionally and will do so in a clang roll in the near
future: llvm/llvm-project#82049

Note that there is a runtime option to make ASAN hook HeapAlloc() but
enabling it breaks Win32 APIs like CreateProcess:
https://crbug.com/368070343#comment29

[email protected]

Bug: 368070343
Change-Id: I4155d4b063980d7849a836dd88f74396a28adef1
Cq-Include-Trybots: luci.chromium.try:linux-rust-x64-dbg,android-rust-arm64-dbg,android-rust-arm32-rel,android-rust-arm64-rel,mac-rust-x64-dbg,linux-rust-x64-rel,win-rust-x64-rel,win-rust-x64-dbg
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5998676
Reviewed-by: Hans Wennborg <[email protected]>
Commit-Queue: danakj <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1379904}
@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 169f58e to cf92c39 Compare November 8, 2024 08:59
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

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

Thanks! I think we're almost there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we expect the program execution to fail with an asan error, we need the "not" prefix. (Also since the asan diagnostic will print to stderr, we should probably redirect it):

// RUN: not %run %t 2>&1 | FileCheck %s

Additionally, the test does not currently work when statically linking against the crt. We need to update asan_malloc_windows_thunk.cpp with the new functions as well.

Comment on lines 144 to 174
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code doesn't actually guarantee the returned pointer will be aligned though.

I think the way to do this is to dllexport an _asan_aligned{malloc,realloc} in asan_malloc_win.cpp, and dllimport and call them here -- look at __asan_malloc for an example.

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 2241d52 to 4bff3cc Compare November 8, 2024 16:08
@mstorsjo mstorsjo requested a review from barcharcraz November 8, 2024 16:25
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

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

Thanks! The test just needs a tweak, then this seems all good to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The ASan errors get printed to stderr. We need to redirect the output so FileCheck sees it. In other words, this line should be

// RUN: not %run %t 2>&1 | FileCheck %s

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Indentation looks off.

Copy link
Member Author

Choose a reason for hiding this comment

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

purposely waited your ok before formatting :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Formatting looks off.

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 4bff3cc to 3c0f86a Compare November 8, 2024 16:56
@devnexen
Copy link
Member Author

devnexen commented Nov 8, 2024

gonna wait @barcharcraz review for good measure.

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 3c0f86a to 00aaeee Compare November 8, 2024 17:03
Copy link
Collaborator

@zmodem zmodem left a comment

Choose a reason for hiding this comment

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

lgtm

@barcharcraz
Copy link

barcharcraz commented Nov 13, 2024

Note that I can no longer speak for the asan team at Microsoft, I've moved to a different team. Still, I'm across the hall from them and I'll review things if I have time.

However, I think things will probably fall apart in programs that use the _aligned_offset_* family of functions. These are freed with _aligned_free but the pointer passed in IS NOT ALIGNED

In hindsight it might have been a bad idea on our end to intercept these functions at all without handling all of them. We ended up breaking basically all applications that used _aligned_offset_*, and fixing it was a bit involved. I think we can share our code in this area, but as I said it's not really my department anymore.

This looks pretty good. We have an implementation of this internally. There should probably be tests of the following:

_aligned_free. Verify behavior is similar between real aligned_free and intercepted w.r.t. stuff allocated with normal malloc
the _dbg variants (these are implemented in terms of the non-debug versions, I think).

@devnexen
Copy link
Member Author

Note that I can no longer speak for the asan team at Microsoft, I've moved to a different team. Still, I'm across the hall from them and I'll review things if I have time.

_aligned_free. Verify behavior is similar between real aligned_free and intercepted w.r.t. stuff allocated with normal malloc the _dbg variants (these are implemented in terms of the non-debug versions, I think).

Not sure about this ; _aligned_free like __asan_free just uses free internally.

@zmodem
Copy link
Collaborator

zmodem commented Nov 14, 2024

Even if there isn't a problem (I think the _aligned_offset_malloc / _aligned_free combo should work), it would be good to expand the test to verify that mixing the intercepted/non-intercepted allocation/freeing functions works.

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch 3 times, most recently from a9e3833 to a8591e2 Compare November 14, 2024 19:31
@zmodem
Copy link
Collaborator

zmodem commented Nov 18, 2024

The latest version of the test fails for me:

--

********************
Testing:  0.. 10.. 20.. 30.. 40
FAIL: AddressSanitizer-x86_64-windows :: TestCases/Windows/aligned_mallocs.cpp (511 of 2773)
******************** TEST 'AddressSanitizer-x86_64-windows :: TestCases/Windows/aligned_mallocs.cpp' FAILED ********************
Exit Code: 1169

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'
# .---command stdout------------
# | libucrt.lib(align.obj) : error LNK2005: _aligned_free already defined in clang_rt.asan_static_runtime_thunk-x86_64.lib(asan_malloc_win_thunk.cpp.obj)
# | libucrt.lib(align.obj) : error LNK2005: _aligned_malloc already defined in clang_rt.asan_static_runtime_thunk-x86_64.lib(asan_malloc_win_thunk.cpp.obj)
# | libucrt.lib(align.obj) : error LNK2005: _aligned_msize already defined in clang_rt.asan_static_runtime_thunk-x86_64.lib(asan_malloc_win_thunk.cpp.obj)
# | libucrt.lib(align.obj) : error LNK2005: _aligned_realloc already defined in clang_rt.asan_static_runtime_thunk-x86_64.lib(asan_malloc_win_thunk.cpp.obj)
# | C:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp : fatal error LNK1169: one or more multiply defined symbols found
# `-----------------------------
# .---command stderr------------
# | clang-cl: error: linker command failed with exit code 1169 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 0x491

--

********************
Testing:  0.. 10.. 20.. 30.. 40
FAIL: AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/aligned_mallocs.cpp (528 of 2773)
******************** TEST 'AddressSanitizer-x86_64-windows-dynamic :: 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      -MD -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_64WindowsDynamicConfig\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 -MD -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_64WindowsDynamicConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp'
# RUN: at line 2
not  C:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\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_64WindowsDynamicConfig\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
# | ==13304==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x118669aa058e 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: ==13304==ERROR: AddressSanitizer: attempting free on address which was not malloc()-ed: 0x118669aa058e in thread T0
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:43'1                ?                                                                                                         possible intended match
# |             3:  #0 0x7ffde9be6e36 in free C:\src\llvm-project\compiler-rt\lib\asan\asan_malloc_win.cpp:71
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             4:  #1 0x7ff6936f1295 in main C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp:39:3
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             5:  #2 0x7ff6936f2653 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             6:  #3 0x7ff6936f2653 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             7:  #4 0x7ffe45857373 (C:\Windows\System32\KERNEL32.DLL+0x180017373)
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

@devnexen
Copy link
Member Author

Ah you re right building this target I can reproduce, I ll have a look later..

@devnexen
Copy link
Member Author

quick question how do you build LLVM ? might be best to align ... I m more used to unixes :) thx

@zmodem
Copy link
Collaborator

zmodem commented Nov 26, 2024

quick question how do you build LLVM ? might be best to align ... I m more used to unixes :) thx

I build with cmake and ninja in a Visual Studio (2019) command prompt. The CMake invocation was probably something like:

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" ..\llvm

(You can probably add -DLLVM_TARGETS_TO_BUILD=X86 to that.)

And then I run the compiler-rt tests with ninja check-compiler-rt.

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 2503312 to 712ae4c Compare November 29, 2024 01:18
@devnexen
Copy link
Member Author

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

@devnexen devnexen requested a review from zmodem December 8, 2024 10:49
@devnexen
Copy link
Member Author

devnexen commented Jan 7, 2025

ping :)

@zmodem
Copy link
Collaborator

zmodem commented Jan 13, 2025

The test fails for me today as well, see below.

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

First, are you sure that check-asan also runs TestCases/Windows/aligned_mallocs.cpp? If not, that could explain why you're not seeing the test failure.

Second, you seem to be hitting a bunch of other test failures, that I'm not seeing. What are the error messages for those?

It doesn't seem like a great use of time to review the patch if it's not even passing its own test.


********************
Testing:  0.. 10.. 20.. 30..
FAIL: AddressSanitizer-x86_64-windows :: TestCases/Windows/aligned_mallocs.cpp (476 of 2782)
******************** 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
# | ==87756==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: ==87756==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 0x7ff910827486 in free C:\src\llvm-project\compiler-rt\lib\asan\asan_malloc_win.cpp:71
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             4:  #1 0x7ff617042643 in free C:\src\llvm-project\compiler-rt\lib\asan\asan_malloc_win_thunk.cpp:52
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             5:  #2 0x7ff6170539dd in _aligned_free_base minkernel\crts\ucrt\src\appcrt\heap\align.cpp:530
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             6:  #3 0x7ff6170539dd in _aligned_free minkernel\crts\ucrt\src\appcrt\heap\align.cpp:543
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             7:  #4 0x7ff617041266 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

--

********************
Testing:  0.. 10.. 20.. 30.. 40
FAIL: AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/aligned_mallocs.cpp (524 of 2782)
******************** TEST 'AddressSanitizer-x86_64-windows-dynamic :: 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      -MD -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_64WindowsDynamicConfig\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 -MD -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_64WindowsDynamicConfig\TestCases\Windows\Output\aligned_mallocs.cpp.tmp'
# RUN: at line 2
not  C:\src\llvm-project\build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\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_64WindowsDynamicConfig\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:17: note: possible intended match here
# | ==44208==ERROR: AddressSanitizer: access-violation on unknown address 0x11b03179ffa7 (pc 0x7ff7042a12f0 bp 0x000000000000 sp 0x007d242ffe00 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: ==44208==ERROR: AddressSanitizer: access-violation on unknown address 0x11b03179ffa7 (pc 0x7ff7042a12f0 bp 0x000000000000 sp 0x007d242ffe00 T0)
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:43'1                     ?                                                                                                                                possible intended match
# |             3: ==44208==The signal is caused by a WRITE memory access.
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             4:  #0 0x7ff7042a12ef in main C:\src\llvm-project\compiler-rt\test\asan\TestCases\Windows\aligned_mallocs.cpp:42:11
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             5:  #1 0x7ff7042a2653 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             6:  #2 0x7ff7042a2653 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             7:  #3 0x7ff96e66259c (C:\WINDOWS\System32\KERNEL32.DLL+0x18001259c)
# | check:43'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

@devnexen
Copy link
Member Author

The test fails for me today as well, see below.

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

First, are you sure that check-asan also runs TestCases/Windows/aligned_mallocs.cpp? If not, that could explain why you're not seeing the test failure.

Second, you seem to be hitting a bunch of other test failures, that I'm not seeing. What are the error messages for those?

It doesn't seem like a great use of time to review the patch if it's not even passing its own test.

Sorry for this. I ll have a look soon-ish. Cheers.

@devnexen
Copy link
Member Author

devnexen commented Jan 13, 2025

So I just did a full clean rebuild (only I rebase from recent main branch)

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" ...

ninja check-compiler-rt

and here the result

image

image

image

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 712ae4c to 9f4f319 Compare January 13, 2025 16:58
@zmodem
Copy link
Collaborator

zmodem commented Jan 21, 2025

So I just did a full clean rebuild (only I rebase from recent main branch)
..
and here the result

Are there any hints in the test output as to why these are failing? Are all the failures for i386, or are there x86_64 failures too?

@devnexen
Copy link
Member Author

Here an example

image

another one

image

and with fuzzer test

image

Are all the failures for i386, or are there x86_64 failures too?

only i386, do I need to do a distinct x86_64 build or is it supposed to test both ? Sorry I m much more used to unixes :)

@zmodem
Copy link
Collaborator

zmodem commented Jan 21, 2025

Can you paste the output as text in a pastebin somewhere? It's hard to see what's going on from the screenshots.

only i386, do I need to do a distinct x86_64 build or is it supposed to test both ? Sorry I m much more used to unixes :)

It's supposed to test both automatically. From the screenshots it's not clear if they all passed on x86_64 or didn't run at all.

@devnexen
Copy link
Member Author

@zmodem
Copy link
Collaborator

zmodem commented Jan 21, 2025

Thanks! It looks like clang-cl is configured to target i386 by default. Maybe that's why it's having problems.

So I just did a full clean rebuild (only I rebase from recent main branch)

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" ...

ninja check-compiler-rt

In what kind of environment did you run cmake? A Visual Studio Command Prompt window? After running VsDevCmd.bat or similar?

Can you try configuring the build in an x86_64 environment, either in an "x64 Native Tools Command Prompt", or after running VsDevCmd.bat -arch=amd64?

@devnexen
Copy link
Member Author

devnexen commented Jan 21, 2025

Well now 64 bits tests are launched I hit the same issues as you.

@devnexen devnexen marked this pull request as draft January 21, 2025 17:39
@devnexen devnexen force-pushed the msan_alloc_aligned_win branch 5 times, most recently from 117f2f1 to 65846ad Compare January 30, 2025 19:58
@devnexen devnexen marked this pull request as ready for review January 30, 2025 20:04
@devnexen
Copy link
Member Author

Here my tests result on this branch

C:/Users/might/repos/64build/./bin/clang.exe  -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -gcodeview -gcolumn-info      -shared-libasan -D_MT -D_DLL -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames -O2 -DTEST_MEMCPY_SIZE_OVERFLOW C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp -o C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp && not  C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp 2>&1 |      FileCheck C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp --check-prefix=CHECK-MEMCPY_SIZE_OVERFLOW
# executed command: C:/Users/might/repos/64build/./bin/clang.exe -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -gcodeview -gcolumn-info -shared-libasan -D_MT -D_DLL -Wl,-nodefaultlib:libcmt,-defaultlib:msvcrt,-defaultlib:oldnames -O2 -DTEST_MEMCPY_SIZE_OVERFLOW 'C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp' -o 'C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp'
# executed command: not 'C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp'
# executed command: FileCheck 'C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp' --check-prefix=CHECK-MEMCPY_SIZE_OVERFLOW
# .---command stderr------------
# | C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp:64:33: error: CHECK-MEMCPY_SIZE_OVERFLOW: expected string not found in input
# |  // CHECK-MEMCPY_SIZE_OVERFLOW: AddressSanitizer: negative-size-param: (size=-1)
# |                                 ^
# | <stdin>:1:1: note: scanning from here
# | =================================================================
# | ^
# | <stdin>:16:1: note: possible intended match here
# | AddressSanitizer can not provide additional info.
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# |             1: =================================================================
# | check:64'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |             2: ==18240==ERROR: AddressSanitizer: access-violation on unknown address 0x12b2ef3e0000 (pc 0x7ff9f908052e bp 0x00ea1c77f750 sp 0x00ea1c77f718 T0)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             3: ==18240==The signal is caused by a READ memory access.
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             4:  #0 0x7ff9f908052d (C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll+0x18001052d)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             5:  #1 0x7ff6776d1065 in main C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp:63:3
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             6:  #2 0x7ff6776d23f3 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# |            11: ==18240==Register values:
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            12: rax = 12b2ef3a0080 rbx = 7ffa1c575e00 rcx = 12b2ef3df1a0 rdx = 12b2ef3dffa0
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            13: rdi = 274ef380000 rsi = ffffffff rbp = ea1c77f750 rsp = ea1c77f718
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            14: r8 = fffffffffffc0edf r9 = ffffffffffffffe0 r10 = 7ff9f9070000 r11 = 7ffa1c64d965
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            15: r12 = 0 r13 = 0 r14 = 0 r15 = 0
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            16: AddressSanitizer can not provide additional info.
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:64'1     ?                                                  possible intended match
# |            17: SUMMARY: AddressSanitizer: access-violation (C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll+0x18001052d)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            18: ==18240==ABORTING
# | check:64'0     ~~~~~~~~~~~~~~~~~~
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--
********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (15):
  AddressSanitizer-Unit :: ./Asan-x86_64-calls-Dynamic-Test.exe/AddressSanitizer/MemCpyOOBTest
  AddressSanitizer-Unit :: ./Asan-x86_64-inline-Dynamic-Test.exe/AddressSanitizer/MemCpyOOBTest
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cpp
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/intercept_memcpy.cpp
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/memset_test.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/hello-world.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/hello-world.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/priority-static-initializer-three.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/priority-static-initializer.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/sehframe-handling.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/static-initializer.S
  ORC-x86_64-windows :: TestCases/Windows/x86-64/static-initializer.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/trivial-atexit.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/trivial-jit-dlopen.c
  libFuzzer-x86_64-default-Windows :: standalone.test


Testing Time: 613.86s

Total Discovered Tests: 3058
  Unsupported      : 1420 (46.44%)
  Passed           : 1588 (51.93%)
  Expectedly Failed:   35 (1.14%)
  Failed           :   15 (0.49%)

15 warning(s) in tests

and main

_MEMCPY_SIZE_OVERFLOW 'C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp' -o 'C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp'
# executed command: not 'C:\Users\might\repos\64build\projects\compiler-rt\test\asan\X86_64WindowsDynamicConfig\TestCases\Output\memset_test.cpp.tmp'
# executed command: FileCheck 'C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp' --check-prefix=CHECK-MEMCPY_SIZE_OVERFLOW
# .---command stderr------------
# | C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp:64:33: error: CHECK-MEMCPY_SIZE_OVERFLOW: expected string not found in input
# |  // CHECK-MEMCPY_SIZE_OVERFLOW: AddressSanitizer: negative-size-param: (size=-1)
# |                                 ^
# | <stdin>:1:1: note: scanning from here
# | =================================================================
# | ^
# | <stdin>:16:1: note: possible intended match here
# | AddressSanitizer can not provide additional info.
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# |             1: =================================================================
# | check:64'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |             2: ==5572==ERROR: AddressSanitizer: access-violation on unknown address 0x12b5788e0000 (pc 0x7ff9f908052e bp 0x0091e12ff8b0 sp 0x0091e12ff878 T0)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             3: ==5572==The signal is caused by a READ memory access.
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             4:  #0 0x7ff9f908052d (C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll+0x18001052d)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             5:  #1 0x7ff690931065 in main C:\Users\might\repos\llvm-project\compiler-rt\test\asan\TestCases\memset_test.cpp:63:3
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             6:  #2 0x7ff6909323f3 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# |            11: ==5572==Register values:
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |            12: rax = 12b5788a0080 rbx = 7ffa1c575e00 rcx = 12b5788df1a0 rdx = 12b5788dffa0
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            13: rdi = 27778880000 rsi = ffffffff rbp = 91e12ff8b0 rsp = 91e12ff878
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            14: r8 = fffffffffffc0edf r9 = ffffffffffffffe0 r10 = 7ff9f9070000 r11 = 7ffa1c64d965
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            15: r12 = 0 r13 = 0 r14 = 0 r15 = 0
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            16: AddressSanitizer can not provide additional info.
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:64'1     ?                                                  possible intended match
# |            17: SUMMARY: AddressSanitizer: access-violation (C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll+0x18001052d)
# | check:64'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            18: ==5572==ABORTING
# | check:64'0     ~~~~~~~~~~~~~~~~~
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
********************
Failed Tests (15):
  AddressSanitizer-Unit :: ./Asan-x86_64-calls-Dynamic-Test.exe/AddressSanitizer/MemCpyOOBTest
  AddressSanitizer-Unit :: ./Asan-x86_64-inline-Dynamic-Test.exe/AddressSanitizer/MemCpyOOBTest
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/dll_intercept_memcpy_indirect.cpp
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/Windows/intercept_memcpy.cpp
  AddressSanitizer-x86_64-windows-dynamic :: TestCases/memset_test.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/hello-world.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/hello-world.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/priority-static-initializer-three.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/priority-static-initializer.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/sehframe-handling.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/static-initializer.S
  ORC-x86_64-windows :: TestCases/Windows/x86-64/static-initializer.cpp
  ORC-x86_64-windows :: TestCases/Windows/x86-64/trivial-atexit.c
  ORC-x86_64-windows :: TestCases/Windows/x86-64/trivial-jit-dlopen.c
  libFuzzer-x86_64-default-Windows :: standalone.test


Testing Time: 601.74s

Total Discovered Tests: 3058
  Unsupported      : 1420 (46.44%)
  Passed           : 1588 (51.93%)
  Expectedly Failed:   35 (1.14%)
  Failed           :   15 (0.49%)

15 warning(s) in tests

@devnexen devnexen force-pushed the msan_alloc_aligned_win branch from 65846ad to 198a56f Compare March 10, 2025 21:30
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.

5 participants