<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61909>61909</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
"Failed to use and restart external symbolizer" with ASAN_OPTIONS=windows_hook_rtl_allocators=true
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
compiler-rt:asan,
platform:windows
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alvinhochun
</td>
</tr>
</table>
<pre>
Building a trivial source with either [llvm-mingw](https://github.com/mstorsjo/llvm-mingw) or the official Windows LLVM 16.0.0 release:
```c++
// clang++ -fsanitize=address -g test.cpp -o test.exe
int main() {
*((volatile int *)nullptr) = 1;
}
```
Running the program normally will give a symbolized backtrace:
```
==15548==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ff640a813e2 bp 0x006ea035f9f0 sp 0x006ea035f9c0 T0)
==15548==The signal is caused by a WRITE memory access.
==15548==Hint: address points to the zero page.
#0 0x7ff640a813e1 in main D:/test.cpp:2:32
[...]
```
However, if the environment variable `ASAN_OPTIONS=windows_hook_rtl_allocators=true` is set, then it fails to start `llvm-symbolizer` and (for mingw-w64 target using DWARF debug info) the backtrace does not contain symbol names and line numbers:
```
==17996==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ff6f54313e2 bp 0x0054f9d0f990 sp 0x0054f9d0f960 T0)
==17996==The signal is caused by a WRITE memory access.
==17996==Hint: address points to the zero page.
==17996==WARNING: Failed to use and restart external symbolizer!
#0 0x7ff6f54313e1 (D:\temp\test.exe+0x1400013e1)
[...]
```
If I set verbosity to 3, the output contains these lines:
```
==10176==Launching symbolizer command: "D:\dev\toolchain\llvm-mingw\llvm-mingw-20230320-ucrt-x86_64\bin/llvm-symbolizer.exe" "--demangle" "--inlines" "--default-arch=x86_64"
==10176==WARNING: AddressSanitizer failed to create process for D:\dev\toolchain\llvm-mingw\llvm-mingw-20230320-ucrt-x86_64\bin/llvm-symbolizer.exe (error code: 87)
```
It appears the `CreateProcessA` call fails with Win32 error code 87 which should be ERROR_INVALID_PARAMETER.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0ll9v2y4Xx18NuTlKRHDsxBe5SOvm-VXquimr1ssK42ObDYMFOGn36h-B3Sbbsz7a9NOqqImP4fz58jkAd042GnFL0iuSFjM--NbYLVdHqVsj2kHPSlO9bK8GqSqpG-DgrTxKrsCZwQqEk_QtoPQtWiDplVLHbt5J3ZxIWhC2ab3vHUl2hO0J2zfSt0O5EKYjbN85b6z7agjbX8xiORgLvkUwdS1FiPQodWVODu7uvnyAZbagCwoWFXKHwTMtCH39n9HxIwi7Cp_RGmODUFw3ox3mteNaevkdSVLwqrLoHMwb8Oj8QvQ9zM34G59xdCK1h45LTdgm5EjWk3MAAMJ20bw5GsW9VAhhdLTmelCq9zbOSQpYkuQ1q3XxU9KXlRwGrYPeQYjemsbyDrSxHVfqBU5SKWjkEYGDe-lKo-R3rKDk4pu3XLyryvSYFCQplmm62ow_bw6HjweS7GA3CvF5ksYGGxcCnZsfZSzNaDAaBv1Nm5OGV-HoM734A8I2vQD6vK7rbEX5Zpkgg7KPwzLkNEnrvKbgfrQICg-UsPydJB9ahMAqVyAdCD64UPELcHg83D7cQIedsS9Tuot3nPwjtY9FTYn3RmrvwJuo83e0Bnre4OJyaRP6YylLkDqSAMXI9SszJNkxkuwSNgVPrxaLReiC91f5H3PCI1rCrkHWMQfUR2mN7lB7OHIreakQSEZ3n3f3Tx8_Pdx-vP9MkuI0tsRTa8y3J-vVE1fKCB4aiiSFtwOSjAahHPrg3beoQXqouVSxXue59cFxbL03iGyYxnUV1rA2FmJPzk_ZCjy3DXoYXKCyeNwd9lBhOTQgdW0C3SH7NwKhMuhAGw_CaB_EGkOA5h26GEFJjaCHrkTrfgvYdZ5nfx_YOl0ll8CmqzqvaJ3nb8C-WrJfAXtO8l8Ae3byZ8D-z_TH3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