[compiler-rt] b1871ce - [sanitizer][win] Change cmdline check to allow double backslashs

Alvin Wong via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 08:00:06 PDT 2023


Author: Alvin Wong
Date: 2023-03-24T22:59:45+08:00
New Revision: b1871ceb1cf6c6954380867d41db3812e9e0dbfc

URL: https://github.com/llvm/llvm-project/commit/b1871ceb1cf6c6954380867d41db3812e9e0dbfc
DIFF: https://github.com/llvm/llvm-project/commit/b1871ceb1cf6c6954380867d41db3812e9e0dbfc.diff

LOG: [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

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
    compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
index c647ab107ec54..ac2afe42e2692 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
@@ -231,8 +231,6 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
     // Check that tool command lines are simple and that complete escaping is
     // unnecessary.
     CHECK(!internal_strchr(arg, '"') && "quotes in args unsupported");
-    CHECK(!internal_strstr(arg, "\\\\") &&
-          "double backslashes in args unsupported");
     CHECK(arglen > 0 && arg[arglen - 1] != '\\' &&
           "args ending in backslash and empty args unsupported");
     command_line.append("\"%s\" ", arg);

diff  --git a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
index c406152e9afa5..81696630bd44f 100644
--- a/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
+++ b/compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cpp
@@ -1,5 +1,5 @@
 // RUN: %clangxx_asan -O0 %s -o %t
-// RUN: %env_asan_opts=external_symbolizer_path=asdf not %run %t 2>&1 | FileCheck %s
+// RUN: %env_asan_opts=external_symbolizer_path=non-existent\\\\asdf not %run %t 2>&1 | FileCheck %s
 
 #include <windows.h>
 #include <dbghelp.h>


        


More information about the llvm-commits mailing list