Skip to content

Commit 1ca4b5c

Browse files
alvinhochuntru
authored andcommitted
[sanitizer][win] Change cmdline check to allow double backslashs
When `llvm-symbolizer.exe` is on the PATH in an entry containing two consecutive backslashes, sanitizers will try to launch llvm-symbolizer with its absolute path containing these consecutive backslashes. This fails a sanity check in `sanitizer_symbolizer_win.cpp`. According to the documentation of `CommandLineToArgvW` [1] and a MS blog post [2], backslashes in general, regardless of how many of them in a row, do not have any special effect, unless when immediately followed by a double quote. There already exists a check that fails when the command line arguments contains double quote, therefore the check for double backslashes can simply be removed. [1]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw [2]: https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way Differential Revision: https://reviews.llvm.org/D146621 (cherry picked from commit b1871ce)
1 parent 973cea7 commit 1ca4b5c

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
231231
// Check that tool command lines are simple and that complete escaping is
232232
// unnecessary.
233233
CHECK(!internal_strchr(arg, '"') && "quotes in args unsupported");
234-
CHECK(!internal_strstr(arg, "\\\\") &&
235-
"double backslashes in args unsupported");
236234
CHECK(arglen > 0 && arg[arglen - 1] != '\\' &&
237235
"args ending in backslash and empty args unsupported");
238236
command_line.append("\"%s\" ", arg);

compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clangxx_asan -O0 %s -o %t
2-
// RUN: %env_asan_opts=external_symbolizer_path=asdf not %run %t 2>&1 | FileCheck %s
2+
// RUN: %env_asan_opts=external_symbolizer_path=non-existent\\\\asdf not %run %t 2>&1 | FileCheck %s
33

44
#include <windows.h>
55
#include <dbghelp.h>

0 commit comments

Comments
 (0)