[compiler-rt] 46282fa - [Sanitizer] Use CreateDirectoryA for report dirs
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 3 12:34:29 PST 2021
Author: Choongwoo Han
Date: 2021-12-03T12:34:05-08:00
New Revision: 46282fad060f623019686919832741eea4ff8bfc
URL: https://github.com/llvm/llvm-project/commit/46282fad060f623019686919832741eea4ff8bfc
DIFF: https://github.com/llvm/llvm-project/commit/46282fad060f623019686919832741eea4ff8bfc.diff
LOG: [Sanitizer] Use CreateDirectoryA for report dirs
Using `_mkdir` of CRT in Asan Init leads to launch failure and hanging in Windows.
You can trigger it by calling:
> set ASAN_OPTIONS=log_path=a/a/a
> .\asan_program.exe
And their crash dump shows the following stack trace:
```
_guard_dispatch_icall_nop()
__acrt_get_utf8_acp_compatibility_codepage()
_mkdir(const char * path)
```
I guess there could be a cfg guard in CRT, which may lead to calling uninitialized cfg guard function address. Also, `_mkdir` supports UTF-8 encoding of the path and calls _wmkdir, but that's not necessary for this case since other file apis in sanitizer_win.cpp assumes only ANSI code case, so it makes sense to use CreateDirectoryA matching other file api calls in the same file.
Reviewed By: tejohnson
Differential Revision: https://reviews.llvm.org/D114760
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
index 1a31ce02af4c..cfe6cc2b394b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
@@ -16,7 +16,6 @@
#define WIN32_LEAN_AND_MEAN
#define NOGDI
-#include <direct.h>
#include <windows.h>
#include <io.h>
#include <psapi.h>
@@ -571,7 +570,9 @@ void Abort() {
internal__exit(3);
}
-bool CreateDir(const char *pathname) { return _mkdir(pathname) == 0; }
+bool CreateDir(const char *pathname) {
+ return CreateDirectoryA(pathname, nullptr) != 0;
+}
#if !SANITIZER_GO
// Read the file to extract the ImageBase field from the PE header. If ASLR is
More information about the llvm-commits
mailing list