<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118596>118596</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Windows: ASAN and other sanitizers not working well with other user and system exception handlers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ccll
</td>
</tr>
</table>
<pre>
On Windows Clang ASAN does intercept system `SetUnhandledExceptionFilter` function to register it's own handler,
and it's behavior is not friendly to other user/system register handlers.
For example:
- User registered handlers not got chained and completely ignored, so we can't write mini dump file upon exception.
- Clang's handler just aborts the process after print a stack trace, and don't return a meaningful value like "EXCEPTION_CONTINUE_SEARCH", thus system registered JIT debugger (windbg, visual studio, etc) will never get called.
The first problem can be mitigated with some hacks.
See [#52739#issuecomment-2516110618](https://github.com/llvm/llvm-project/issues/52739#issuecomment-2516110618)
But the second problem is difficult to solve from the user's side.
The ideal process should be like this:
- program crashes due to address/UB error
- clang caught it, print a message and stack trace, then pass the error down the chain (please don't just die and exit)
- the next user handler caught it, write a mini dump file for analysis/debugging, then pass the error down the chain
- (on my development machine) the system JIT debugger caught it, and fire up a debug session, ...
Hope this would get better.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVc2O2zgTfBr60oghU5Z_Djo4zhjJd5h82JnB7i2gyJbEDEUK7JY93qdfkPI4m1x2sSfDJPunuqpaish2HrEW1UdRfVqoifsQa62dWzTBXOuvHn633oQLwdEp38Hh6fAIJiCB9YxR48hAV2IcQGyKJ-QX3ytvHJqHt3Rpgz9ZxxjFpoB28jqdAAeI2FlijGBZyC1BuHiYI6OQR1EclDfvdw326mxDBEvgA0MbLXrjrilP4B4jTJTCTrdO7rlvCWkpioMoDqcQAd_UMDoUZTr4AC-E8f4ezT0i1-kCg-6V9WggtaNDCmV0V7CdDxGNkEegABcErbyQW4ZLtIwwWG_BTMMIrXUI0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