[compiler-rt] r276314 - Fix clang-cl warning and crash in sanitizers

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 11:31:02 PDT 2016


Author: rnk
Date: Thu Jul 21 13:31:01 2016
New Revision: 276314

URL: http://llvm.org/viewvc/llvm-project?rev=276314&view=rev
Log:
Fix clang-cl warning and crash in sanitizers

Make kStderrFd a macro to avoid dynamic initialization of the
report_file global. This actually causes a crash at runtime, because
ASan initializes before static initializers run.

Remove an unused variable in asan_win.cc.

Modified:
    compiler-rt/trunk/lib/asan/asan_win.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h

Modified: compiler-rt/trunk/lib/asan/asan_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_win.cc?rev=276314&r1=276313&r2=276314&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_win.cc Thu Jul 21 13:31:01 2016
@@ -236,7 +236,6 @@ void AsanOnDeadlySignal(int, void *sigin
 static LONG CALLBACK
 ShadowExceptionHandler(PEXCEPTION_POINTERS exception_pointers) {
   static uptr page_size = GetPageSizeCached();
-  static uptr alloc_granularity = GetMmapGranularity();
   // Only handle access violations.
   if (exception_pointers->ExceptionRecord->ExceptionCode !=
       EXCEPTION_ACCESS_VIOLATION) {

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h?rev=276314&r1=276313&r2=276314&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Thu Jul 21 13:31:01 2016
@@ -62,10 +62,12 @@ int internal_snprintf(char *buffer, uptr
 bool mem_is_zero(const char *mem, uptr size);
 
 // I/O
-const fd_t kInvalidFd = (fd_t)-1;
-const fd_t kStdinFd = 0;
-const fd_t kStdoutFd = (fd_t)1;
-const fd_t kStderrFd = (fd_t)2;
+// Define these as macros so we can use them in linker initialized global
+// structs without dynamic initialization.
+#define kInvalidFd ((fd_t)-1)
+#define kStdinFd ((fd_t)0)
+#define kStdoutFd ((fd_t)1)
+#define kStderrFd ((fd_t)2)
 
 uptr internal_ftruncate(fd_t fd, uptr size);
 




More information about the llvm-commits mailing list