This implements a FIXME in the runtime library and adds printing the address at the end of the message as "by 0x123abc". The buffer for the message is allocated on the stack in a handler, so the stack memory consumption is slightly increased. No additional external dependencies are added.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Unfortunately, I have no idea how to check the new output. Will be grateful for any suggestions.
Can you add/update few tests?
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | ||
---|---|---|
23–26 | looks unrelated, can you land it separately, no review is needed | |
54 | why do we need noinline here? | |
59 | please don't skip them and match %p style | |
65 | you can avoid updating mask with: | |
94 | Can we have "@" -> "at 0x"? |
Sorry, didn't notice on the first pass.
my favorite way for find test on unknown code is to brake code around and run all tests: check-all
something like this and "ninja check-ubsan-minimal"
diff --git a/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c b/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c index 08696c81e573..763261dda1d5 100644 --- a/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c +++ b/compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) { void *t = __builtin_assume_aligned(ptr + 1, 0x8000); (void)t; - // CHECK: ubsan: alignment-assumption + // CHECK: ubsan: alignment-assumption at 0x{{[0-9af]}} // CHECK-NOT: alignment-assumption free(ptr);
maybe update all these few test cases in the dir
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | ||
---|---|---|
94 |
Looks like we mostly use "at" for load/store location |
Thanks for the review!
- An NFC part is committed as https://reviews.llvm.org/rG1959a55591da
- Print leading zeroes,
- "@..." -> "by 0x...",
- Update tests, except recover-dedup-limit.cpp, because that change would only add some noise and not any value to it.
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | ||
---|---|---|
54 | report_this_error() has the attribute, so I decided to follow that here. It seems to correspond to the intention to make the library as small as possible. | |
94 | Changed to "by 0x". |
compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp | ||
---|---|---|
93 | constexpr unsigned kAddrBuf = ... static is redundant for const. But when constexpr works, prefer constexpr instead. | |
compiler-rt/test/ubsan_minimal/TestCases/alignment-assumption.c | ||
11 | Note: [[#%x,]] can replace {{[[:xdigit:]]+}} but here we match $ too which requires {{$}}, I think xdigit is fine, too. |
looks unrelated, can you land it separately, no review is needed