[asan/win] Delay load dbghelp.dll to delay ucrtbase.dll initialization
authorReid Kleckner <rnk@google.com>
Mon, 14 Nov 2016 17:37:50 +0000 (17:37 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 14 Nov 2016 17:37:50 +0000 (17:37 +0000)
commite1e344ed05bb83787ed90524154b7b04ddc49759
tree7eed96551312dd925d2a4f67d8f5dd2d3f9182e2
parent4dc0ed83905af9b48c94b640757c260781d60fd0
[asan/win] Delay load dbghelp.dll to delay ucrtbase.dll initialization

Summary:
ASan needs to initialize before ucrtbase.dll so that it can intercept
all of its heap allocations. New versions of dbghelp.dll depend on
ucrtbase.dll, which means both of those DLLs will initialize before the
dynamic ASan runtime. By lazily loading dbghelp.dll with LoadLibrary, we
avoid the issue.

Eventually, I would like to remove our dbghelp.dll dependency in favor
of always using llvm-symbolizer.exe, but this seems like an acceptable
interim solution.

Fixes PR30903

Reviewers: etienneb

Subscribers: kubabrecka, mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D26473

llvm-svn: 286848
compiler-rt/lib/sanitizer_common/sanitizer_dbghelp.h [new file with mode: 0644]
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cc
compiler-rt/lib/sanitizer_common/sanitizer_win.cc
compiler-rt/test/CMakeLists.txt
compiler-rt/test/asan/TestCases/Windows/delay_dbghelp.cc [new file with mode: 0644]