[PATCH] D12181: [sanitizer] Add -fsanitize-trap-function.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 15:51:19 PDT 2015


rsmith added a comment.

In http://reviews.llvm.org/D12181#234590, @jmgao wrote:

> Ping, I think @samsonov was waiting on @rsmith's feedback on the following:
>
> In http://reviews.llvm.org/D12181#229493, @jmgao wrote:
>
> > The goal is to be able to give a useful fsanitize-specific error message ("fsanitize trap occurred"), while not lying and saying this for non-sanitize traps.
>


My original intent was that users who wanted a different response to sanitizer failures would provide an alternative runtime library (defining the `__ubsan_handle_*` functions to do whatever they wanted). The trap mechanism was added for users who didn't want the code size increase of generating the calls to a handler function. I worry that we're piling on more and more ways of responding to ubsan failures with no underlying principled design.

Without this patch, you have (at least) two options:

1. Use `-fsanitize-trap` and `-ftrap-function=`. You'll get calls on sanitizer failures, and also on explicit calls to `__builtin_trap()`. If we added a sanitizer for reaching `__builtin_trap()` -- which doesn't seem completely unreasonable -- these would all be sanitizer failures :)
2. Use your own ubsan runtime library. There are about 20 functions you'd need to define, but you can define them all to be aliases of the same handler function. See ubsan_handlers.h in compiler-rt for a list of the symbols you need to provide.

Given the above, do you think your patch adds enough value to be worth our time to maintain?


http://reviews.llvm.org/D12181





More information about the cfe-commits mailing list