<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Internal error in AddressSanitizer on Windows on "bad" %PATH% format: "double backslashes in args unsupported""
href="https://bugs.llvm.org/show_bug.cgi?id=45606">45606</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Internal error in AddressSanitizer on Windows on "bad" %PATH% format: "double backslashes in args unsupported"
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>asan
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andre.brand@mailbox.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23389" name="attach_23389" title="Minimal example to trigger the issue">attachment 23389</a> <a href="attachment.cgi?id=23389&action=edit" title="Minimal example to trigger the issue">[details]</a></span>
Minimal example to trigger the issue
=Overview=
ASAN crashes on Windows during error reporting:
<span class="quote">> AddressSanitizer CHECK failed: C:\src\llvm_package_901-final\llvm\projects\compiler-rt\lib\sanitizer_common\sanitizer_symbolizer_win.cc:234 "((!internal_strstr(arg, "\\\\") && "double backslashes in args unsupported")) != (0)" (0x0, 0x0)</span >
when you add LLVM to the environment via
<span class="quote">> set "PATH=%PATH%;C:\Program Files\LLVM\\bin"</span >
(Note the double backslashes.)
This happens a lot in Windows when you use other environment variables:
<span class="quote">> set "PATH=%PATH%;%LLVM_DIR%\bin"</span >
People often add the extra backslash because you don't know if %LLVM_DIR% ends
with a backslash and it usually does no harm.
It took me a while to track that down because you kind of suspect that the
issue lies within the application path or some kind of Short/Long path
weirdness in Windows.
=Steps to Reproduce=
Add LLVM to the %PATH% via (adjust install dir if necessary):
<span class="quote">> set "PATH=%PATH%;C:\Program Files\LLVM\\bin"</span >
Then run a minimal example with ASAN:
<span class="quote">> clang-cl main.cpp -fsanitize=address && main.exe</span >
I attached a simple example that triggers ASAN (main.cpp) and the compiler
invocations that lead to the crash (compile_bad.bat). I confirmed that it works
without the double backslashes (compile_good.bat).
=Actual Results=
ASAN crashes on Windows during error reporting:
<span class="quote">> ==27040==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x11a6dd900278 at pc 0x7ff6c8411077 bp 0x000d84effc00 sp 0x000d84effc48
> WRITE of size 4 at 0x11a6dd900278 thread T0
> ==27040==AddressSanitizer CHECK failed: C:\src\llvm_package_901-final\llvm\projects\compiler-rt\lib\sanitizer_common\sanitizer_symbolizer_win.cc:234 "((!internal_strstr(arg, "\\\\") && "double backslashes in args unsupported")) != (0)" (0x0, 0x0)</span >
=Expected Results=
Of course, it would be nice if it just worked even with the double backslashes.
But since it is trivial to work around that as a user as soon as you know which
path is the problem, it would be a huge win if you extend the error message:
"... where args=C:\Program Files\LLVM\\bin".
So you can find that out without having to compile clang.
=Build Date & Hardware=
Tested with clang-9.0.1 and clang-10.0.0 on Windows 7 and Windows 10 Version
1909. I am quite certain that my hardware doesn't matter.
=Additional Builds and Platforms=
See above.
=Additional Information=
I guess this is easy to reproduce. If not, I'd be happy to provide further
information, callstacks, etc.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>