Skip to content
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

[win/asan] Support instructions in GetInstructionSize used by Wine. #113085

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

bernhardu
Copy link
Contributor

@bernhardu bernhardu commented Oct 20, 2024

This patch adds several instructions seen when trying to run a executable built with ASan with llvm-mingw,
with the tip of the main branch from llvm-project (x86 and x86_64). Also another missing instruction visible in the issue 96270.

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Also changes "44 0f b6 1a" to return 4 instead of 5 (MR 111638). Got fixed in 8417f6a.

Fixes: #96270

Co-authored-by: Roman Pišl
https://bugs.winehq.org/show_bug.cgi?id=50993
https://bugs.winehq.org/attachment.cgi?id=70233

Co-authored-by: Eric Pouech
https://bugs.winehq.org/show_bug.cgi?id=52386
https://bugs.winehq.org/attachment.cgi?id=71626

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from 3eae6a0 to de7be9d Compare October 20, 2024 20:48
@bernhardu
Copy link
Contributor Author

v2:

  • Added another instruction "81 ec XX XX XX XX" which showed up using clang to compile the 32-bit PE side of Wine.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from de7be9d to 52ae811 Compare October 20, 2024 22:41
@bernhardu
Copy link
Contributor Author

v3:

  • Another few instructions, which showed up after getting the wine build working, with the 64-bit clang PE side.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from 52ae811 to 2665318 Compare October 25, 2024 20:21
@bernhardu
Copy link
Contributor Author

bernhardu commented Oct 25, 2024

v4:

  • rebase over the recent fix 8417f6a
  • add a few more instructions found when trying more applications.

@zmodem Thanks for the offer, and sorry for the delay.
I wonder if this has chances to go in, as it targets not a native windows platform?
And for "41 b8 XX XX XX XX : mov r8d, XX XX XX XX" I am not sure if it should
also consider rel_offset, but I don't know how to test this.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from 2665318 to f1dbbb2 Compare November 5, 2024 13:08
@bernhardu
Copy link
Contributor Author

v5:

  • Rebase to current tip.
  • Improve commit comment (hopefully).

@bernhardu bernhardu changed the title Support in GetInstructionSize instructions used by Wine. [win/asan] Support instructions in GetInstructionSize used by Wine. Nov 5, 2024
@bernhardu bernhardu marked this pull request as ready for review November 5, 2024 13:10
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

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

Author: None (bernhardu)

Changes

This patch adds several instructions seen when trying to run a executable built with ASan with llvm-mingw,
with the tip of the main branch from llvm-project (x86 and x86_64). Also another missing instruction visible in the issue 96270.

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Also changes "44 0f b6 1a" to return 4 instead of 5 (MR 111638). Got fixed in 8417f6a.

Fixes: #96270

Co-authored-by: Roman Pišl
https://bugs.winehq.org/show_bug.cgi?id=50993
https://bugs.winehq.org/attachment.cgi?id=70233

Co-authored-by: Eric Pouech
https://bugs.winehq.org/show_bug.cgi?id=52386
https://bugs.winehq.org/attachment.cgi?id=71626


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

1 Files Affected:

  • (modified) compiler-rt/lib/interception/interception_win.cpp (+73)
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 077a536dd2a3103..e0d15a49e171dcb 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -528,6 +528,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
 
     case 0xb8:  // b8 XX XX XX XX : mov eax, XX XX XX XX
     case 0xB9:  // b9 XX XX XX XX : mov ecx, XX XX XX XX
+    case 0xBA:  // ba XX XX XX XX : mov edx, XX XX XX XX
       return 5;
 
     // Cannot overwrite control-instruction. Return 0 to indicate failure.
@@ -558,16 +559,31 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xFF8B:  // 8B FF : mov edi, edi
     case 0xEC8B:  // 8B EC : mov ebp, esp
     case 0xc889:  // 89 C8 : mov eax, ecx
+    case 0xD189:  // 89 D1 : mov ecx, edx
     case 0xE589:  // 89 E5 : mov ebp, esp
     case 0xC18B:  // 8B C1 : mov eax, ecx
+    case 0xC031:  // 31 C0 : xor eax, eax
+    case 0xC931:  // 31 C9 : xor ecx, ecx
+    case 0xD231:  // 31 D2 : xor edx, edx
     case 0xC033:  // 33 C0 : xor eax, eax
     case 0xC933:  // 33 C9 : xor ecx, ecx
     case 0xD233:  // 33 D2 : xor edx, edx
     case 0xDB84:  // 84 DB : test bl,bl
+    case 0xC084:  // 84 C0 : test al,al
     case 0xC984:  // 84 C9 : test cl,cl
     case 0xD284:  // 84 D2 : test dl,dl
       return 2;
 
+    case 0x3980:  // 80 39 XX : cmp BYTE PTR [rcx], XX
+    case 0xE483:  // 83 E4 XX : and esp, XX
+    case 0x4D8B:  // 8B 4D XX : mov XX(%ebp), ecx
+    case 0x558B:  // 8B 55 XX : mov XX(%ebp), edx
+    case 0x758B:  // 8B 75 XX : mov XX(%ebp), esp
+      return 3;
+
+    case 0xec81:  // 81 ec XX XX XX XX : sub esp, XX XX XX XX
+      return 6;
+
     // Cannot overwrite control-instruction. Return 0 to indicate failure.
     case 0x25FF:  // FF 25 XX XX XX XX : jmp [XXXXXXXX]
       return 0;
@@ -577,6 +593,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xF8E483:  // 83 E4 F8 : and esp, 0xFFFFFFF8
     case 0x64EC83:  // 83 EC 64 : sub esp, 64h
       return 3;
+    case 0x244C8D:  // 8D 4C 24 XX : lea ecx, [esp + XX]
+      return 4;
     case 0x24A48D:  // 8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]
       return 7;
   }
@@ -643,6 +661,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0x7980:  // 80 79 YY XX  cmp BYTE ptr [rcx+YY], XX
       return 4;
 
+    case 0xb841:  // 41 b8 XX XX XX XX : mov r8d, XX XX XX XX
+      return 6;
     case 0x058B:  // 8B 05 XX XX XX XX : mov eax, dword ptr [XX XX XX XX]
       if (rel_offset)
         *rel_offset = 2;
@@ -673,6 +693,9 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xc1ff48:    // 48 ff c1 : inc rcx
     case 0xc1ff49:    // 49 ff c1 : inc r9
     case 0xc28b41:    // 41 8b c2 : mov eax, r10d
+    case 0x01b60f:    // 0f b6 01 : movzx eax, BYTE PTR [rcx]
+    case 0x09b60f:    // 0f b6 09 : movzx ecx, BYTE PTR [rcx]
+    case 0x11b60f:    // 0f b6 11 : movzx edx, BYTE PTR [rcx]
     case 0xc2b60f:    // 0f b6 c2 : movzx eax, dl
     case 0xc2ff48:    // 48 ff c2 : inc rdx
     case 0xc2ff49:    // 49 ff c2 : inc r10
@@ -691,6 +714,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xc98548:    // 48 85 c9 : test rcx, rcx
     case 0xc9854d:    // 4d 85 c9 : test r9, r9
     case 0xc98b4c:    // 4c 8b c9 : mov r9, rcx
+    case 0xd12948:    // 48 29 d1 : sub rcx, rdx
     case 0xca2b48:    // 48 2b ca : sub rcx, rdx
     case 0xca3b48:    // 48 3b ca : cmp rcx, rdx
     case 0xd12b48:    // 48 2b d1 : sub rdx, rcx
@@ -700,17 +724,34 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0xd2854d:    // 4d 85 d2 : test r10, r10
     case 0xd28b4c:    // 4c 8b d2 : mov r10, rdx
     case 0xd2b60f:    // 0f b6 d2 : movzx edx, dl
+    case 0xd2be0f:    // 0f be d2 : movsx edx, dl
     case 0xd98b4c:    // 4c 8b d9 : mov r11, rcx
     case 0xd9f748:    // 48 f7 d9 : neg rcx
+    case 0xc03145:    // 45 31 c0 : xor r8d,r8d
+    case 0xc93145:    // 45 31 c9 : xor r9d,r9d
     case 0xdb3345:    // 45 33 db : xor r11d, r11d
+    case 0xc08445:    // 45 84 c0 : test r8b,r8b
+    case 0xd28445:    // 45 84 d2 : test r10b,r10b
     case 0xdb8548:    // 48 85 db : test rbx, rbx
     case 0xdb854d:    // 4d 85 db : test r11, r11
     case 0xdc8b4c:    // 4c 8b dc : mov r11, rsp
     case 0xe0e483:    // 83 e4 e0 : and esp, 0xFFFFFFE0
     case 0xe48548:    // 48 85 e4 : test rsp, rsp
     case 0xe4854d:    // 4d 85 e4 : test r12, r12
+    case 0xc88948:    // 48 89 c8 : mov rax,rcx
+    case 0xcb8948:    // 48 89 cb : mov rbx,rcx
+    case 0xd08948:    // 48 89 d0 : mov rax,rdx
+    case 0xd18948:    // 48 89 d1 : mov rcx,rdx
+    case 0xd38948:    // 48 89 d3 : mov rbx,rdx
     case 0xe58948:    // 48 89 e5 : mov rbp, rsp
     case 0xed8548:    // 48 85 ed : test rbp, rbp
+    case 0xc88949:    // 49 89 c8 : mov r8, rcx
+    case 0xc98949:    // 49 89 c9 : mov r9, rcx
+    case 0xca8949:    // 49 89 ca : mov r10,rcx
+    case 0xd08949:    // 49 89 d0 : mov r8, rdx
+    case 0xd18949:    // 49 89 d1 : mov r9, rdx
+    case 0xd28949:    // 49 89 d2 : mov r10, rdx
+    case 0xd38949:    // 49 89 d3 : mov r11, rdx
     case 0xed854d:    // 4d 85 ed : test r13, r13
     case 0xf6854d:    // 4d 85 f6 : test r14, r14
     case 0xff854d:    // 4d 85 ff : test r15, r15
@@ -721,6 +762,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
     case 0x588948:    // 48 89 58 XX : mov QWORD PTR[rax + XX], rbx
     case 0xec8348:    // 48 83 ec XX : sub rsp, XX
     case 0xf88349:    // 49 83 f8 XX : cmp r8, XX
+    case 0x148d4e:    // 4e 8d 14 XX : lea r10, [rcx+r8*XX]
+    case 0x398366:    // 66 83 39 XX : cmp WORD PTR [rcx], XX
       return 4;
 
     case 0x246483:  // 83 64 24 XX YY :   and    DWORD PTR [rsp+XX], YY
@@ -735,6 +778,7 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
       return 6;
 
     case 0xec8148:    // 48 81 EC XX XX XX XX : sub rsp, XXXXXXXX
+    case 0xc0c748:    // 48 c7 c0 XX XX XX XX : mov rax, XX XX XX XX
       return 7;
 
     // clang-format off
@@ -768,7 +812,13 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
   }
 
   switch (*(u32*)(address)) {
+    case 0x01b60f44:  // 44 0f b6 01 : movzx r8d, BYTE PTR [rcx]
+    case 0x09b60f44:  // 44 0f b6 09 : movzx r9d, BYTE PTR [rcx]
+    case 0x0ab60f44:  // 44 0f b6 0a : movzx r8d, BYTE PTR [rdx]
+    case 0x11b60f44:  // 44 0f b6 11 : movzx r10d, BYTE PTR [rcx]
     case 0x1ab60f44:  // 44 0f b6 1a : movzx r11d, BYTE PTR [rdx]
+    case 0x11048d4c:  // 4c 8d 04 11 : lea r8,[rcx+rdx*1]
+    case 0xff488d49:  // 49 8d 48 ff : lea rcx,[r8-0x1]
       return 4;
     case 0x24448b48:  // 48 8b 44 24 XX : mov rax, QWORD ptr [rsp + XX]
     case 0x246c8948:  // 48 89 6C 24 XX : mov QWORD ptr [rsp + XX], rbp
@@ -785,6 +835,29 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
       return 5;
     case 0x24648348:  // 48 83 64 24 XX YY : and QWORD PTR [rsp + XX], YY
       return 6;
+    case 0x24A48D48:  // 48 8D A4 24 XX YY ZZ WW : lea rsp, [rsp + WWZZYYXX]
+      return 8;
+  }
+
+  switch (0xFFFFFFFFFFULL & *(u64*)(address)) {
+    case 0xC07E0F4866:  // 66 48 0F 7E C0 : movq rax,xmm0 (for wine fexp)
+    case 0x0000441F0F:  // 0F 1F 44 00 00 : nop DWORD PTR [rax+rax*1+0x0]
+      return 5;
+  }
+
+  switch (0xFFFFFFFFFFFFULL & *(u64*)(address)) {
+    case 0x841f0f2e6666:  // 66 66 2e 0f 1f 84 YY XX XX XX XX
+                          // data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]
+      return 11;
+  }
+
+  switch (*(u64*)(address)) {
+    case 0x010101010101b848: // 48 b8 01 01 01 01 01 01 01 01
+                             // movabs rax,0x101010101010101
+      return 10;
+    case 0x841f0f2e66666666:  // 66 66 66 66 2e 0f 1f 84 YY XX XX XX XX
+                              // data16 data16 data16 cs nop WORD PTR [rax+rax*1 + XX XX XX XX]
+      return 13;
   }
 
 #else

@bernhardu
Copy link
Contributor Author

bernhardu commented Nov 5, 2024

Unfortunately just found and will probably change in next version, depending on feedback.

  • 83 E4 F8 : and esp, 0xFFFFFFF8 and 83 e4 e0 : and esp, 0xFFFFFFE0
    should be already handled by 83 E4 XX : and esp, XX

  • 83 EC 64 : sub esp, 64h should be handled by 83 EC XX : sub esp, XX

  • Should't 8A 05 XX XX XX XX return 6, currently it does return 4.
    Is it ok to just change it in the same commit, separate commit, or separte PR?

  • Still unsure how to handle (or test) rel_offset?
    I hope I understand now - rel_offset is just how many bytes to skip from the instruction to extract the offset.

  • Make f6 c1 07 : test cl, 0x7 also a generic instruction like f6 c1 XX : test cl, XX?

  • Should this patch be split up in a few more chunks, or some parts taken out into a different PR?

@bernhardu bernhardu force-pushed the 96270_interception_win branch from f1dbbb2 to 45dccde Compare November 6, 2024 23:21
@bernhardu
Copy link
Contributor Author

bernhardu commented Nov 6, 2024

v6:

  • split off the changes modifying existing lines in separate commits.
  • Added a simple test for known instructions.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from 415800e to 59dff96 Compare November 7, 2024 15:02
@bernhardu
Copy link
Contributor Author

v7:

  • Found with the test a duplicate instruction, removed the line which got never reached.
  • Split the test addition into different commits.

Sorry for the ongoing changes, please drop me a note if some commits should go into a separate PR.

Copy link
Collaborator

@rnk rnk left a comment

Choose a reason for hiding this comment

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

@zmodem, are you able to review this at some point?

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

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

If this interacts with 8417f6a, can you rebase this change past that, to make things clearer with how it fits together with that?

compiler-rt/lib/interception/interception_win.cpp Outdated Show resolved Hide resolved
@bernhardu
Copy link
Contributor Author

If this interacts with 8417f6a, can you rebase this change past that, to make things clearer with how it fits together with that?

Since the comment "v4" it is already rebased behind 8417f6a, so this should make no problems.
But I see now there was another commit to this file in cdfd4cf. It seems to make no conflict, but should I still rebase over this one?

Thanks for having a look.
So should I mark this PR as draft again, and feed in separate PRs for easier review?

@mstorsjo
Copy link
Member

If this interacts with 8417f6a, can you rebase this change past that, to make things clearer with how it fits together with that?

Since the comment "v4" it is already rebased behind 8417f6a, so this should make no problems. But I see now there was another commit to this file in cdfd4cf. It seems to make no conflict, but should I still rebase over this one?

Thanks for having a look. So should I mark this PR as draft again, and feed in separate PRs for easier review?

Ah, ok, I see.

As I'm not qualified enough to really review this, I would hold off of updating it until some of those who might be (@rnk, @zmodem, @vitalybuka or @barcharcraz) says which way they prefer to handle it.

As for adding the extra #ifs to silence warnings due to the unused code blocks - just file that in a separate PR which I can accept quite quickly.

@bernhardu
Copy link
Contributor Author

... The policy within llvm is ... that PRs are merged with "squash and merge" ...

Oh, I was not aware of this, so this seems also to suggest to use the separate PR approach, Thanks.

@@ -643,6 +664,8 @@ static size_t GetInstructionSize(uptr address, size_t* rel_offset = nullptr) {
case 0x7980: // 80 79 YY XX cmp BYTE ptr [rcx+YY], XX
return 4;

case 0xB841: // 41 B8 XX XX XX XX : mov r8d, XX XX XX XX
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks wrong. The second operand is an immediate, not a relative offset, so it shouldn't be leading to a branch that sets rel_offset.

compiler-rt/lib/interception/interception_win.cpp Outdated Show resolved Hide resolved
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.

Sorry for the delay, I'll try to prioritize this.

I did a first pass, but didn't spot check any of the actual encodings yet. If you do have some parts that could be separate PRs, that would be helpful.

compiler-rt/lib/interception/interception_win.cpp Outdated Show resolved Hide resolved
case 0x75FF: // FF 75 XX : push dword ptr [ebp + XX]
return 3;
case 0xC1F7: // F7 C1 XX YY ZZ WW : test ecx, WWZZYYXX
case 0x25FF: // FF 25 XX YY ZZ WW : jmp dword ptr ds:[WWZZYYXX]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened to this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found this when I created the test.
There is a similar line some lines above which returns 0 as failure for a jmp instruction.

Splitted of this PR: Remove duplicate instruction FF 25 ....
#116894

compiler-rt/lib/interception/interception_win.h Outdated Show resolved Hide resolved
SIZE_T rel_offset;
} data[] = {
/* sort list */
{ 0, { 0x70, 0x71 }, 0 }, // 70 71 : jo XX (short conditional jump)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment somewhere explain that 0 means "cannot override"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in the splitted PR.

u8 instr[16];
SIZE_T rel_offset;
} data[] = {
/* sort list */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you use any tooling to generate these tests? If so, maybe add a comment about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately not, I was basically just copying GetInstructionSize
and editing with notepad++`s multi-line-edit and macro feature.

Comment on lines 1077 to 1079
<< std::setfill('0') << std::setw(2) << std::right << std::hex << (int)data[i].instr[0] << " "
<< std::setfill('0') << std::setw(2) << std::right << std::hex << (int)data[i].instr[1] << " "
<< std::setfill('0') << std::setw(2) << std::right << std::hex << (int)data[i].instr[2] << " "
Copy link
Collaborator

Choose a reason for hiding this comment

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

There could be more than 3 bytes though. Maybe call a utility function that returns a hex string instead? (same below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in the splitted PR.

@bernhardu bernhardu force-pushed the 96270_interception_win branch from 62ee9f2 to c12c753 Compare December 1, 2024 14:35
@bernhardu bernhardu force-pushed the 96270_interception_win branch from c12c753 to 92e234f Compare December 14, 2024 04:07
TIFitis pushed a commit to TIFitis/llvm-project that referenced this pull request Dec 18, 2024
….`. (llvm#116894)

It appears already some lines above with this comment:
  "Cannot overwrite control-instruction. Return 0 to indicate failure.".

Replacing just the comment in the first appearance.

Found after creating the test in llvm#113085.
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
…ions.

This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Related: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
…ructions.

This patch adds several instructions seen when trying to run a
executable built with ASan with llvm-mingw.
(x86 and x86_64, using the git tip in llvm-project).

Also includes instructions collected by
Roman Pišl and Eric Pouech in the Wine bug reports below.

Fixes: llvm#96270

Co-authored-by: Roman Pišl <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=50993
                https://bugs.winehq.org/attachment.cgi?id=70233
Co-authored-by: Eric Pouech <[email protected]>
                https://bugs.winehq.org/show_bug.cgi?id=52386
                https://bugs.winehq.org/attachment.cgi?id=71626
ASAN_OPTIONS='verbosity=0:windows_hook_rtl_allocators=1' WINEDLLOVERRIDES="$F=n;*.dll=n" WINEDEBUG= wine64 z:/home/bernhard/data/entwicklung/2024/wine/wine-build/build-asan-pe/64/obj/dlls/urlmon/tests/x86_64-windows/urlmon_test.exe url

urlmon_test:url

ASAN_OPTIONS='verbosity=0:windows_hook_rtl_allocators=1' WINEDLLOVERRIDES="$F=n;*.dll=n" WINEDEBUG= wine64 z:/home/bernhard/data/entwicklung/2024/wine/wine-build/build-asan-pe/64/obj/dlls/urlmon/tests/x86_64-windows/urlmon_test.exe url
...
url.c:3528: Test marked todo: expected GetWindow_ICodeInstall
url.c:4077: file test (no callback)...
0130:err:secur32:establish_context alloc_buffer=00007FFFFE1FC510, alloc_buffer.pvBuffer=00007F331B4D0800 RtlGetLastWin32Error(): 0x0 :979
0130:err:secur32:establish_context alloc_buffer=00007FFFFE1FC510, alloc_buffer.pvBuffer=00007F331B4D0800 RtlGetLastWin32Error(): 0x0 :982
=================================================================
==300==ERROR: AddressSanitizer: attempting double-free on 0x7f331b4d0800 in thread T0:
022c:fixme:file:server_get_file_info Unsupported info class e
    #0 0x6ffffa60b113 in RtlFreeHeap /home/bernhard/data/entwicklung/2024/llvm-mingw/2024-10-18/llvm-mingw/llvm-project/compiler-rt\lib/asan/asan_malloc_win.cpp:444:3
    llvm#1 0x6ffff346345f in FreeContextBuffer /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\secur32.c:651:5
    llvm#2 0x6ffffc2b6cd3 in netcon_secure_connect_setup /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:484:13
    llvm#3 0x6ffffc2a8216 in NETCON_secure_connect /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:612:11
    llvm#4 0x6ffffc295941 in HTTP_HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5100:23
    llvm#5 0x6ffffc29b999 in HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5759:8
    llvm#6 0x6ffffc29b2ab in HttpSendRequestA /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5799:14
    llvm#7 0x0001400dfa52 in can_do_https /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:3987:11
    llvm#8 0x0001400dfa52 in func_url /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:4080:12
    llvm#9 0x00014011cd90 in run_test /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:765:5
    llvm#10 0x00014011cd90 in main /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:884:12
    llvm#11 0x00014011ec3f in mainCRTStartup /home/bernhard/data/entwicklung/2024/wine\wine/dlls/msvcrt/crt_main.c:58:11
    llvm#12 0x6fffffa54808 in BaseThreadInitThunk /home/bernhard/data/entwicklung/2024/wine/wine/dlls/kernel32\thread.c:61:5
    llvm#13 0x6fffffc2fa1a in RtlUserThreadStart (C:\windows\system32\ntdll.dll+0x17000fa1a)

0x7f331b4d0800 is located 0 bytes inside of 65536-byte region [0x7f331b4d0800,0x7f331b4e0800)
freed by thread T0 here:
    #0 0x6ffffa60abc6 in __asan::SharedReAlloc(void* (*)(void*, unsigned long, void*, unsigned long long), unsigned long long (*)(void*, unsigned long, void*), int (*)(void*, unsigned long, void*), void* (*)(void*, unsign
ed long, unsigned long long), void*, unsigned long, void*, unsigned long long) /home/bernhard/data/entwicklung/2024/llvm-mingw/2024-10-18/llvm-mingw/llvm-project/compiler-rt\lib/asan/asan_malloc_win.cpp:269:3
    llvm#1 0x6ffffa60afa4 in HeapReAlloc /home/bernhard/data/entwicklung/2024/llvm-mingw/2024-10-18/llvm-mingw/llvm-project/compiler-rt\lib/asan/asan_malloc_win.cpp:394:10
    llvm#2 0x6ffff346858d in establish_context.constprop.0 /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\schannel.c:980:13
    llvm#3 0x6ffff3464680 in InitializeSecurityContextW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\wrapper.c:249:19
    llvm#4 0x6ffffc2b6bdf in netcon_secure_connect_setup /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:464:14
    llvm#5 0x6ffffc2a8216 in NETCON_secure_connect /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:612:11
    llvm#6 0x6ffffc295941 in HTTP_HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5100:23
    llvm#7 0x6ffffc29b999 in HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5759:8
    llvm#8 0x6ffffc29b2ab in HttpSendRequestA /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5799:14
    llvm#9 0x0001400dfa52 in can_do_https /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:3987:11
    llvm#10 0x0001400dfa52 in func_url /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:4080:12
    llvm#11 0x00014011cd90 in run_test /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:765:5
    llvm#12 0x00014011cd90 in main /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:884:12
    llvm#13 0x00014011ec3f in mainCRTStartup /home/bernhard/data/entwicklung/2024/wine\wine/dlls/msvcrt/crt_main.c:58:11
    llvm#14 0x6fffffa54808 in BaseThreadInitThunk /home/bernhard/data/entwicklung/2024/wine/wine/dlls/kernel32\thread.c:61:5
    llvm#15 0x6fffffc2fa1a in RtlUserThreadStart (C:\windows\system32\ntdll.dll+0x17000fa1a)

previously allocated by thread T0 here:
    #0 0x6ffffa60a8a3 in HeapAlloc /home/bernhard/data/entwicklung/2024/llvm-mingw/2024-10-18/llvm-mingw/llvm-project/compiler-rt\lib/asan/asan_malloc_win.cpp:230:3
    llvm#1 0x6ffff3468098 in establish_context.constprop.0 /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\schannel.c:954:37
    llvm#2 0x6ffff3464680 in InitializeSecurityContextW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\wrapper.c:249:19
    llvm#3 0x6ffffc2b6bdf in netcon_secure_connect_setup /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:464:14
    llvm#4 0x6ffffc2a8216 in NETCON_secure_connect /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\netconnection.c:612:11
    llvm#5 0x6ffffc295941 in HTTP_HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5100:23
    llvm#6 0x6ffffc29b999 in HttpSendRequestW /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5759:8
    llvm#7 0x6ffffc29b2ab in HttpSendRequestA /home/bernhard/data/entwicklung/2024/wine/wine/dlls/wininet\http.c:5799:14
    llvm#8 0x0001400dfa52 in can_do_https /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:3987:11
    llvm#9 0x0001400dfa52 in func_url /home/bernhard/data/entwicklung/2024/wine\wine/dlls/urlmon/tests/url.c:4080:12
    llvm#10 0x00014011cd90 in run_test /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:765:5
    llvm#11 0x00014011cd90 in main /home/bernhard/data/entwicklung/2024/wine\wine/include/wine/test.h:884:12
    llvm#12 0x00014011ec3f in mainCRTStartup /home/bernhard/data/entwicklung/2024/wine\wine/dlls/msvcrt/crt_main.c:58:11
    llvm#13 0x6fffffa54808 in BaseThreadInitThunk /home/bernhard/data/entwicklung/2024/wine/wine/dlls/kernel32\thread.c:61:5
    llvm#14 0x6fffffc2fa1a in RtlUserThreadStart (C:\windows\system32\ntdll.dll+0x17000fa1a)

SUMMARY: AddressSanitizer: double-free /home/bernhard/data/entwicklung/2024/wine/wine/dlls/secur32\secur32.c:651:5 in FreeContextBuffer
==300==ABORTING
This is probably just important with `-DCMAKE_BUILD_TYPE=RelWithDebInfo`.
Just stumbled over following, and found a -O3 while looking for the
missing variables/parameter debug info, removed by -gline-tables-only.
Not sure if really needed.

llvm:CMakeLists.txt:1232
if( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
  # People report that -O3 is unreliable on MinGW. The traditional
  # build also uses -O2 for that reason:
  llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
endif()
`-ftrivial-auto-var-init=pattern` emits `memset` to initialize variables,
but with half-way intercepted functions this is problematic.

Can also be switched off per function with `__declspec(no_init_all)`.



Program received signal SIGSEGV, Segmentation fault.
0x7a80f51f in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
87        COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, dst, v, size);
1: x/i $pc
=> 0x7a80f51f <__asan_wrap_memset(void*, int, __sanitizer::usize)+335>: push   %eax
(rr) bt 10
#0  0x7a80f51f in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#1  0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#2  0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#3  0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
...
llvm#9168 0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#9169 0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#9170 0x7a80f44b in __asan_wrap_memset (dst=0x121ed78, v=255, size=400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#9171 0x7a7db0c7 in __sanitizer::SharedPrintfCode (append_pid=false, format=0x7a82b160 <.refptr.___ImageBase+4> "%s: CHECK failed: %s:%d \"%s\" (0x%zx, 0x%zx) (tid=%u)\n", args=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_printf.cpp:308
llvm#9172 0x0000000c in ?? ()


(rr) disassemble __sanitizer::SharedPrintfCode
Dump of assembler code for function _ZN11__sanitizerL16SharedPrintfCodeEbPKcPc:
   0x7a7db0a0 <+0>:     push   %ebp
   0x7a7db0a1 <+1>:     push   %ebx
   0x7a7db0a2 <+2>:     push   %edi
   0x7a7db0a3 <+3>:     push   %esi
   0x7a7db0a4 <+4>:     sub    $0x190,%esp
   0x7a7db0aa <+10>:    mov    %edx,%esi
   0x7a7db0ac <+12>:    mov    %ecx,%edi
   0x7a7db0ae <+14>:    mov    0x1a4(%esp),%ebp
   0x7a7db0b5 <+21>:    mov    %esp,%ebx
   0x7a7db0b7 <+23>:    push   $0x190
   0x7a7db0bc <+28>:    push   $0xff
   0x7a7db0c1 <+33>:    push   %ebx
=> 0x7a7db0c2 <+34>:    call   0x7a823bc6 <memset>
   0x7a7db0c7 <+39>:    add    $0xc,%esp
   0x7a7db0ca <+42>:    mov    %edi,%ecx
   0x7a7db0cc <+44>:    mov    %ebx,%edx
   0x7a7db0ce <+46>:    push   %ebp
   0x7a7db0cf <+47>:    push   %esi
   0x7a7db0d0 <+48>:    call   0x7a7db5c0 <_ZN11__sanitizerL24SharedPrintfCodeNoBufferEbPciPKcS0_>
   0x7a7db0d5 <+53>:    add    $0x198,%esp
   0x7a7db0db <+59>:    pop    %esi
   0x7a7db0dc <+60>:    pop    %edi
   0x7a7db0dd <+61>:    pop    %ebx
   0x7a7db0de <+62>:    pop    %ebp
   0x7a7db0df <+63>:    ret
End of assembler dump.


With the `no_init_all` ASan prints:
AddressSanitizer: CHECK failed: asan_suppressions.cpp:46 "((suppression_ctx)) != (0)" (0x0, 0x0) (tid=36)


Unfortunately it looks like this draws in almost all dlls ...

                    /* llvm-symbolizer.exe, avoid loading libclang_rt.asan_dynamic-i386.dll too early */
                    strstr(make->module, "msvcp140.dll") ||
                    strstr(make->module, "vcruntime140.dll") ||
                    strstr(make->module, "concrt140.dll") ||
                    strstr(make->module, "advapi32.dll") ||
                    strstr(make->module, "sechost.dll") ||
                    strstr(make->module, "gdi32.dll") ||
                    strstr(make->module, "oleaut32.dll") ||
                    strstr(make->module, "imm32.dll") ||
                    strstr(make->module, "rpcrt4.dll") ||
                    strstr(make->module, "combase.dll") ||
                    strstr(make->module, "ole32.dll") ||
                    strstr(make->module, "iphlpapi.dll") ||
                    strstr(make->module, "dnsapi.dll") ||
                    strstr(make->module, "netapi32.dll") ||
                    strstr(make->module, "nsi.dll") ||
                    strstr(make->module, "ws2_32.dll") ||

                    strstr(make->module, "winspool.drv") ||
                    strstr(make->module, "compstui.dll") ||
                    strstr(make->module, "comctl32.dll") ||
                    strstr(make->module, "comctl32.dll") ||

and more ... but it looked working with x86_64 ?
…ternal.

- Get atexit table initialized before we intall interception.
- Do InitializeSuppressions a little earlier


(With LLVM-19.1.6-win32.exe)
ASAN_OPTIONS=verbosity=2 wine "C:\\Program Files\\LLVM\\bin\\llvm-symbolizer.exe"

AddressSanitizer: CHECK failed: asan_suppressions.cpp:46 "((suppression_ctx)) != (0)" (0x0, 0x0) (tid=324)
AddressSanitizer: CHECK failed: asan_suppressions.cpp:46 "((suppression_ctx)) != (0)" (0x0, 0x0) (tid=324)

(rr) bt
#0  __sanitizer::CheckFailed (file=0x7a892243 <.refptr.___asan_shadow_memory_dynamic_address+491> "/home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_suppressions.cpp", line=46, cond=0x7a8922e4 <.refptr.___asan_shadow_memory_dynamic_address+652> "((suppression_ctx)) != (0)", v1=0, v2=0) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:83
llvm#1  0x7a8772bc in __asan::IsInterceptorSuppressed (interceptor_name=0x7a890364 <.refptr.___asan_option_detect_stack_use_after_return+9824> "memset") at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_suppressions.cpp:46
llvm#2  0x7a86c071 in __asan_wrap_memset (dst=0x302ba000, v=254, size=8192) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#3  0x7a86e563 in __asan::FastPoisonShadow (aligned_beg=<optimized out>, aligned_size=<optimized out>, value=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_poisoning.h:55
llvm#4  __asan::PoisonShadow (addr=22872064, size=65536, value=254 '\376') at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_poisoning.cpp:43
llvm#5  0x7a875c43 in __asan::OnLowLevelAllocate (ptr=22872064, size=65536) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:106
llvm#6  0x7a832835 in __sanitizer::LowLevelAllocator::Allocate (this=0x7b14d138, size=16400) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cpp:159
llvm#7  0x7a84d3ba in operator new (size=16396, alloc=...) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common.h:1112
llvm#8  __sanitizer::ChooseSymbolizerTools (list=<optimized out>, allocator=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp:299
llvm#9  __sanitizer::Symbolizer::PlatformInit () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp:312
llvm#10 0x7a849834 in __sanitizer::Symbolizer::GetOrInit () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp:24
llvm#11 0x7a848378 in __sanitizer::(anonymous namespace)::StackTraceTextPrinter::ProcessAddressFrames (this=this@entry=0x121ead4, pc=2055691253) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:37
llvm#12 0x7a8482c1 in __sanitizer::StackTrace::PrintTo (this=this@entry=0x121eb30, output=0x121eb14) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:110
llvm#13 0x7a8485e1 in __sanitizer::StackTrace::Print (this=0x121eb30) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:133
llvm#14 0x7a875c21 in __asan::CheckUnwind () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:70
llvm#15 0x7a843f03 in __sanitizer::CheckFailed (file=0x7a892243 <.refptr.___asan_shadow_memory_dynamic_address+491> "/home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_suppressions.cpp", line=46, cond=0x7a8922e4 <.refptr.___asan_shadow_memory_dynamic_address+652> "((suppression_ctx)) != (0)", v1=0, v2=0) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_termination.cpp:86
llvm#16 0x7a8772bc in __asan::IsInterceptorSuppressed (interceptor_name=0x7a890364 <.refptr.___asan_option_detect_stack_use_after_return+9824> "memset") at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_suppressions.cpp:46
llvm#17 0x7a86c071 in __asan_wrap_memset (dst=0x30300000, v=250, size=131072) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87
llvm#18 0x7a86e563 in __asan::FastPoisonShadow (aligned_beg=<optimized out>, aligned_size=<optimized out>, value=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_poisoning.h:55
llvm#19 __asan::PoisonShadow (addr=25165824, size=1048576, value=250 '\372') at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_poisoning.cpp:43
llvm#20 0x7a856c54 in __asan::AsanMapUnmapCallback::OnMap (p=25165824, size=1048576, this=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:283
llvm#21 __sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> >::AllocateRegion (stat=0x7b1777e4, this=<optimized out>, class_id=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_primary32.h:304
llvm#22 __sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> >::PopulateFreeList (this=0x7b14ec40, stat=0x7b1777e4, c=0x7b170be4, sci=0x7b14ff40, class_id=12) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_primary32.h:343
llvm#23 0x7a856b97 in __sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> >::AllocateBatch (this=<optimized out>, stat=0x7b1777e4, c=0x7b170be4, class_id=12) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_primary32.h:174
llvm#24 0x7a856a2b in __sanitizer::SizeClassAllocator32LocalCache<__sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> > >::Refill (this=this@entry=0x7b170be4, c=0x7b1723e4, allocator=0x7b14ec40, class_id=12) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_local_cache.h:244
llvm#25 0x7a8575f5 in __sanitizer::SizeClassAllocator32LocalCache<__sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> > >::Allocate (this=0x7b170be4, allocator=0x7b14ec40, class_id=131072) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_local_cache.h:164
llvm#26 __sanitizer::CombinedAllocator<__sanitizer::SizeClassAllocator32<__asan::AP32<__sanitizer::LocalAddressSpaceView> >, __sanitizer::LargeMmapAllocatorPtrArrayStatic>::Allocate (this=this@entry=0x7b14ec40, cache=0x7b170be4, size=<optimized out>, alignment=8) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_allocator_combined.h:69
llvm#27 0x7a85545b in __asan::Allocator::Allocate (this=<optimized out>, size=<optimized out>, alignment=8, stack=0x121f5c0, alloc_type=__asan::FROM_MALLOC, can_fill=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:586
llvm#28 0x7a853aee in __asan::Allocator::Calloc (nmemb=32, size=4, stack=0x121f5c0, this=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:787
llvm#29 __asan::asan_calloc (nmemb=32, size=4, stack=0x121f5c0) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_allocator.cpp:1012
llvm#30 0x7a86cd43 in calloc (nmemb=32, size=4) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_malloc_win.cpp:92
llvm#31 0x7b493543 in register_onexit_function (table=table@entry=0x7a89b160 <atexit_table>, func=func@entry=0x7a844430 <__sanitizer_cov_dump()>) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/msvcrt/exit.c:80
llvm#32 0x7b493a54 in _register_onexit_function (table=0x7a89b160 <atexit_table>, func=0x7a844430 <__sanitizer_cov_dump()>) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/msvcrt/exit.c:443
llvm#33 0x7a83139e in atexit (func=<optimized out>) at ../crt/crtdll.c:209
llvm#34 0x7a841f6d in __sanitizer::Atexit (function=0x7a844430 <__sanitizer_cov_dump()>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp:752
llvm#35 0x7a84440f in __sanitizer::InitializeCoverage (enabled=64, dir=0x7a87f9f6 <.refptr.__ZN11__sanitizer24stoptheworld_tracer_ppidE+42> ".") at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp:214
llvm#36 0x7a844430 in __sanitizer::InitializeCoverage(bool, char const*) () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp:216
llvm#37 0x0121fa7c in ?? ()
llvm#38 0x7a8757ab in __asan::AsanInitInternal () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:474
llvm#39 0x7a875fa0 in __asan::AsanInitFromRtl () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:522
llvm#40 __asan::AsanInitializer::AsanInitializer (this=<optimized out>) at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:542
llvm#41 __cxx_global_var_init () at /home/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/lib/asan/asan_rtl.cpp:546
llvm#42 0x7a875fa0 in _GLOBAL__sub_I_asan_rtl.cpp () from /media/bernhard/data/entwicklung/2025/llvm-mingw/2025-01-04/llvm-mingw/llvm-project/compiler-rt/build-i686-sanitizers/lib/windows/libclang_rt.asan_dynamic-i386.dll
llvm#43 0x0121fd24 in ?? ()
llvm#44 0x7a87cb9b in __do_global_ctors () at ../crt/gccmain.c:44
llvm#45 __main () at ../crt/gccmain.c:58
llvm#46 0x7a831222 in __DllMainCRTStartup (hDllHandle=0x7a830000, dwReason=1, lpreserved=<optimized out>) at ../crt/crtdll.c:185
llvm#47 0x7a8311af in _DllMainCRTStartup@12 (hDllHandle=<optimized out>, dwReason=<optimized out>, lpreserved=<optimized out>) at ../crt/crtdll.c:156
llvm#48 0x7bdf63d6 in call_dll_entry_point () from /mnt/sdb1/wineprefix_asan_2025-01-01_win32/drive_c/windows/system32/ntdll.dll
llvm#49 0x7bdf96e0 in MODULE_InitDLL (wm=<optimized out>, wm@entry=0x243bd0, reason=reason@entry=1, lpReserved=0x121fd24) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/ntdll/loader.c:1668
llvm#50 0x7bdf7b42 in process_attach (node=<optimized out>, lpReserved=lpReserved@entry=0x121fd24) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/ntdll/loader.c:1762
llvm#51 0x7bdfa4d8 in loader_init (context=0x121fd24, entry=0x121fdd4) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/ntdll/loader.c:4456
llvm#52 0x7be18b2c in _LdrInitializeThunk@16 (context=0x121fd24, unk2=0, unk3=0, unk4=0) at /home/bernhard/data/entwicklung/2024/wine/wine/dlls/ntdll/signal_i386.c:559
llvm#53 0xdeadbabe in ?? ()
@bernhardu bernhardu force-pushed the 96270_interception_win branch from 92e234f to 26cc342 Compare January 11, 2025 15:04
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.

asan does not work in wine.
6 participants