Index: compiler-rt/lib/asan/asan_poisoning.h =================================================================== --- compiler-rt/lib/asan/asan_poisoning.h +++ compiler-rt/lib/asan/asan_poisoning.h @@ -38,7 +38,7 @@ // performance-critical code with care. ALWAYS_INLINE void FastPoisonShadow(uptr aligned_beg, uptr aligned_size, u8 value) { - DCHECK(CanPoisonMemory()); + DCHECK(!value || CanPoisonMemory()); uptr shadow_beg = MEM_TO_SHADOW(aligned_beg); uptr shadow_end = MEM_TO_SHADOW( aligned_beg + aligned_size - SHADOW_GRANULARITY) + 1; Index: compiler-rt/lib/asan/asan_poisoning.cc =================================================================== --- compiler-rt/lib/asan/asan_poisoning.cc +++ compiler-rt/lib/asan/asan_poisoning.cc @@ -32,7 +32,7 @@ } void PoisonShadow(uptr addr, uptr size, u8 value) { - if (!CanPoisonMemory()) return; + if (value && !CanPoisonMemory()) return; CHECK(AddrIsAlignedByGranularity(addr)); CHECK(AddrIsInMem(addr)); CHECK(AddrIsAlignedByGranularity(addr + size)); Index: compiler-rt/test/asan/TestCases/handle_noreturn_bug.cc =================================================================== --- /dev/null +++ compiler-rt/test/asan/TestCases/handle_noreturn_bug.cc @@ -0,0 +1,13 @@ +// Regression test: __asan_handle_no_return should unpoison stack even with poison_heap=0. +// RUN: %clangxx_asan -O0 %s -o %t && \ +// RUN: %env_asan_opts=poison_heap=1 %run %t && \ +// RUN: %env_asan_opts=poison_heap=0 %run %t + +#include + +int main(int argc, char **argv) { + int x[2]; + int * volatile p = &x[0]; + __asan_handle_no_return(); + int volatile z = p[2]; +}