[PATCH] D131914: [ubsan-minimal] Report the address of an error

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 13:58:49 PDT 2022


vitalybuka added a comment.

Can you add/update few tests?



================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:23-26
+__attribute__((noinline)) static bool
+report_this_error(__sanitizer::uptr caller) {
+  if (caller == 0)
+    return false;
----------------
looks unrelated, can you land it separately, no review is needed


================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:55
 
+__attribute__((noinline)) static void decorate_msg(char *buf,
+                                                   __sanitizer::uptr caller) {
----------------
why do we need noinline here?


================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:60
+  // skip leading zeroes
+  while (shift > 0 && !(caller & mask)) {
+    mask >>= 4;
----------------
please don't skip them and match %p style
sanitizers usually don't skip 0s


================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:66
+  for (;;) {
+    unsigned int nibble = (caller & mask) >> shift;
+    *(buf++) = nibble < 10 ? nibble + '0' : nibble - 10 + 'a';
----------------
you can avoid updating mask with:
unsigned int nibble = (caller >> shift) & 0xf;


================
Comment at: compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:105
+static const unsigned int kMaxAddrBuf = SANITIZER_WORDSIZE / 4;
+#define MSG_TMPL(msg) "ubsan: " msg " @"
+#define MSG_TMPL_END(buf, msg) (buf + sizeof(MSG_TMPL(msg)) - 1)
----------------
Can we have "@" -> "at 0x"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131914



More information about the llvm-commits mailing list