[cfe-dev] [ubsan] Add -fsanitize-warn-once, only emit runtime error once per check

Will Dietz willdtz at gmail.com
Thu Dec 13 11:51:12 PST 2012


On Thu, Dec 13, 2012 at 12:05 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> On Thu, Dec 13, 2012 at 7:33 PM, Will Dietz <willdtz at gmail.com> wrote:
>> This flag causes clang to emit a byte for each check that is used by the
>> runtime to track whether we've already printed an error for that check.
>>
>>  Often failed checks are triggered many times dynamically, but a user
>>  is only interested in which checks failed (with example dynamic values
>>  to aid in debugging).  This flag lets the user make such runs much
>>  more efficient and generate more manageable output.
>
> Hi Will,
>
> +  if (Checked) {
> +    if (*Checked) return;
> +    *Checked = true;
> +  }
>
> Does it make sense to do the store atomically?  The user's program is
> already buggy, but introducing a possible data race is unfortunate.
>
> Dmitri
>

Hi Dmitri,

Glad you brought this up.  I wasn't sure which way to go on this and
erred on simplicity.  Attached is an updated compiler-rt patch using
__sync_val_compare_and_swap, which also simplifies the code a bit.  If
this builtin is sufficiently portable (architectures and compiler
recognition) then I would prefer this for the reasons you mention.

Thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ubsan-Add-fsanitize-warn-once-only-emit-runtime-erro.patch
Type: application/octet-stream
Size: 15950 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121213/89a3f520/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ubsan-Support-fsanitize-warn-once-only-warn-first-ti.patch
Type: application/octet-stream
Size: 18174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121213/89a3f520/attachment-0001.obj>


More information about the cfe-dev mailing list