[all-commits] [llvm/llvm-project] 832b3b: Modify BoundsSan to improve debuggability (#65972)

Oskar Wirga via All-commits all-commits at lists.llvm.org
Fri Sep 29 15:34:45 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 832b3b2462c1bb8e2b41ef96fe0ffd3791df0e12
      https://github.com/llvm/llvm-project/commit/832b3b2462c1bb8e2b41ef96fe0ffd3791df0e12
  Author: Oskar Wirga <10386631+oskarwirga at users.noreply.github.com>
  Date:   2023-09-29 (Fri, 29 Sep 2023)

  Changed paths:
    M clang/lib/CodeGen/CGExpr.cpp
    M clang/test/CodeGen/bounds-checking.c
    M llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
    A llvm/test/Instrumentation/BoundsChecking/ubsan-unique-traps.ll
    A llvm/test/MC/AArch64/local-bounds-single-trap.ll

  Log Message:
  -----------
  Modify BoundsSan to improve debuggability (#65972)

Context
BoundsSanitizer is a mitigation that is part of UBSAN. It can be enabled
in "trap" mode to crash on OOB array accesses.

Problem
BoundsSan has zero false positives meaning every crash is a OOB array
access, unfortunately optimizations cause these crashes in production
builds to be a bit useless because we only know which function is
crashing but not which line of code.

Godbolt example of the optimization: https://godbolt.org/z/6qjax9z1b

This Diff
I wanted to provide a way to know exactly which LOC is responsible for
the crash. What we do here is use the size of the basic block as an
iterator to an immediate value for the ubsan trap.

Previous discussion: https://reviews.llvm.org/D148654




More information about the All-commits mailing list