[asan] Add exception handler to map memory on demand on Win64.
Memory will be committed on demand when exception happens while accessing
shadow memeory region.
Details
Diff Detail
Event Timeline
lib/asan/asan_win.cc | ||
---|---|---|
227 | Does this can be done into: InitializeExceptionHandlerOnWindows64 | |
244 | no { } here | |
265 | 'auto' here won't comply with the common coding style in llvm. | |
271 | ditto 'auto' | |
280 | rewrite the following list has a single line. if (AddVectoredExceptionHandler(TRUE, &ShadowExceptionHandler) != nullptr) or if (!AddVectoredExceptionHandler(TRUE, &ShadowExceptionHandler)) |
lib/asan/asan_win.cc | ||
---|---|---|
257 | As I get it, for the shadow memory this should never happens??? |
lib/asan/asan_internal.h | ||
---|---|---|
65 | I'm not a fan of these #ifdef Should we use something similar than: void InitializePlatformInterceptors(); |
lib/asan/asan_internal.h | ||
---|---|---|
65 | Sounds reasonable. Could be called InitializePlatformExceptionHandlers() ? |
lib/asan/asan_win.cc | ||
---|---|---|
257 | This is cut and paste from a small test harness I wrote. Because of the page table overhead on Win7, I was tinkering with not even reserving the shadow at all, and had added this support. I think it simpler if we just say only Win8+ is recommended for x64, and document the page table overhead for Win7. This is better than the potential correctness problem that can result if somebody else gets memory where we think we have the shadow. |
lib/asan/asan_win.cc | ||
---|---|---|
257 | Yes. This piece of code was ported from a test program (credits to chrisha). I thought for a while and it should be not useful in the case of windows 10, apart from being defensive code. For window 7, I am not quite sure what's the behavior. One thing that I would like to test is, VirtualAlloc() seems to have alignment requirement of allocation granularity for any flag involving MEM_RESERVE, if I understand correctly. For MEM_COMMIT only flag, address only have to be aligned with page size. |
lib/sanitizer_common/sanitizer_win.cc | ||
---|---|---|
171 | I see, this function also used in dfsan, esan etc. The name is already confusing.. It says "NoReserve" yet we are passing MEM_RESERVE flag.. |
This CL is not compiling.
Please fix:
../llvm/llvm/projects/compiler-rt/lib/asan/asan_win.cc:232: Lines should be <= 80 characters long [whitespace/line_length] [2] ../llvm/llvm/projects/compiler-rt/lib/asan/asan_win.cc:249: Lines should be <= 80 characters long [whitespace/line_length] [2]
and this
projects/compiler-rt/lib/asan/CMakeFiles/RTAsan_dynamic.x86_64.dir/asan_rtl.cc.o: In function `AsanInitInternal': /usr/local/google/home/etienneb/llvm/llvm/projects/compiler-rt/lib/asan/asan_rtl.cc:423: undefined reference to `__asan::InitializePlatformExceptionHandlers()' collect2: error: ld returned 1 exit status
FYI, this broke tsan. Only asan installs vectored SEH handler. I fixed it in:
http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?r1=276112&r2=276111&pathrev=276112
I'm not a fan of these #ifdef
Should we use something similar than: void InitializePlatformInterceptors();
but for the shadow.