[all-commits] [llvm/llvm-project] 1b71ea: [msan] Automatically print shadow for failing outl...

Thurston Dang via All-commits all-commits at lists.llvm.org
Tue Jun 24 15:10:05 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1b71ea411a9d36705663b1724ececbdfec7cc98c
      https://github.com/llvm/llvm-project/commit/1b71ea411a9d36705663b1724ececbdfec7cc98c
  Author: Thurston Dang <thurston at google.com>
  Date:   2025-06-24 (Tue, 24 Jun 2025)

  Changed paths:
    M compiler-rt/lib/msan/msan.cpp
    M compiler-rt/lib/msan/msan_interface_internal.h
    A compiler-rt/test/msan/msan_print_shadow_on_outlined_check.cpp
    M llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    M llvm/test/Instrumentation/MemorySanitizer/with-call-type-size.ll

  Log Message:
  -----------
  [msan] Automatically print shadow for failing outlined checks (#145107)

A commonly used aid for debugging MSan reports is `__msan_print_shadow()`, which requires manual app code annotations (typically of the variable in the UUM report or nearby). This is in contrast to ASan, which automatically prints out the shadow map when a check fails.

This patch changes MSan to print the shadow that failed an outlined check (checks are outlined per function after the `-msan-instrumentation-with-call-threshold` is exceeded) if verbosity >= 1. Note that we do not print out the shadow map of "neighboring" variables because this is technically infeasible; see "Caveat" below.

This patch can be easier to use than `__msan_print_shadow()` because this does not require manual app code annotations. Additionally, due to optimizations, `__msan_print_shadow()` calls can sometimes spuriously affect whether a variable is initialized.

As a side effect, this patch also enables outlined checks for arbitrary-sized shadows (vs. the current hardcoded handlers for {1,2,4,8}-byte shadows).

Caveat: the shadow does not necessarily correspond to an individual user variable, because MSan instrumentation may combine and/or truncate multiple shadows prior to emitting a check that the mangled shadow is zero (e.g., `convertShadowToScalar()`, `handleSSEVectorConvertIntrinsic()`, `materializeInstructionChecks()`). OTOH it is arguably a strength that this feature emit the shadow that directly matters for the MSan check, but which cannot be obtained using the MSan API.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list