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.