[PATCH] D29463: [asan] Intercept SetUnhandledExceptionFilter.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 10:45:27 PST 2017


mpividori created this revision.
Herald added a subscriber: kubamracek.

In this diff I update the code for asan on Windows, so we can intercept `SetUnhandledExceptionFilter` and catch some exceptions depending on the result of `IsHandledDeadlyException()` (which depends on asan flags).
This way we have the same behavior on Windows and Posix systems.
On Posix, we intercept signal and sigaction, so user's code can only register signal handlers for signals that are not handled by asan.
The same on Windows, after this diff, user's code can only register exception handlers for exceptions that are not handled by asan.

In particular, this is necessary for libFuzzer:

On Posix, libFuzzer registers signals handlers for SIGFPE, SIGSEGV, SIGILL, etc. If the code is compiled with `-fsanitize=address`, asan library will intercept `sigaction` and register its own signals handlers for SIGFPE, SIGSEGV, SIGILL (depending on asan flags).  So, when the code being fuzzed generates a signal, like SIGFPE, it will be handled by asan, not by libFuzzer.

We want the same behavior for Windows. After this diff, libFuzzer registers exception handlers with `SetUnhandledExceptionFilter`. Asan library will intercept `SetUnhandledExceptionFilter` and register it own exception handler for exceptions like `EXCEPTION_FLT_DIVIDE_BY_ZERO`, etc (depending on asan flags).  So, when the code being fuzzed generates an exception, like  `EXCEPTION_FLT_DIVIDE_BY_ZERO`, it will be handled by asan, not by libFuzzer.


https://reviews.llvm.org/D29463

Files:
  lib/asan/asan_win.cc
  test/asan/TestCases/Windows/dll_host.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29463.86845.patch
Type: text/x-patch
Size: 4131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170202/3d1488e1/attachment.bin>


More information about the llvm-commits mailing list