[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 05:56:23 PDT 2019


lebedev.ri updated this revision to Diff 221929.
lebedev.ri edited the summary of this revision.
lebedev.ri added a comment.

Rebased. 
I've added most (?) of the obviously-missing folds.
This improved situation, although admittedly by not as much as i had hoped.

ping @vsk; can this get going please? live miscompiles aren't fun i suspect :)

> In D67122#1659721 <https://reviews.llvm.org/D67122#1659721>, @vsk wrote:
> 
>> Still think this looks good. Have you tried running this on the llvm test suite, or some other interesting corpus? Would be curious to see any pre/post patch numbers.
> 
> 
> <...>
> 
> TLDR: (all measurements done with llvm ToT, the sanitizer never fired.)
> 
> - no sanitization vs. existing check: average `+20.75%` slowdown
> - existing check vs. check after this patch: average `+26.36%` slowdown
> - no sanitization vs. this patch: average `+52.58%` slowdown

New numbers:
F10080220: rawspeed-pointer-overflow-0-baseline.json <https://reviews.llvm.org/F10080220> F10080221: rawspeed-pointer-overflow-1-old.json <https://reviews.llvm.org/F10080221> F10080223: rawspeed-pointer-overflow-2-new.json <https://reviews.llvm.org/F10080223>
TLDR: (all measurements done with llvm ToT, the sanitizer never fired.)

- no sanitization vs. existing check: average `+21.62%` slowdown (`+0.87%`, noise?)
- existing check vs. check after this patch: average `22.04%` slowdown (`-4.32%` yay)
- no sanitization vs. this patch: average `48.42%` slowdown (`-4.16%` yay)

In D67122#1680063 <https://reviews.llvm.org/D67122#1680063>, @xbolva00 wrote:

> Did you run it with the linux kernel? It could be interesting
>
> cc @nickdesaulniers


It can't **possibly** matter for them, they treat null pointer as defined.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67122/new/

https://reviews.llvm.org/D67122

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-overflow-volatile.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/CodeGen/ubsan-pointer-overflow.m
  clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp
  compiler-rt/lib/ubsan/ubsan_checks.inc
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/index-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-constants.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-summary.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-variable.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
  compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
  llvm/docs/ReleaseNotes.rst

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67122.221929.patch
Type: text/x-patch
Size: 103949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190926/48dbf2fc/attachment-0001.bin>


More information about the cfe-commits mailing list