Summary: As explained in https://bugs.llvm.org/show_bug.cgi?id=46208, symbolization on Windows after inlining and around lambdas/std::functions doesn't work very well. Under the new pass manager, there is inlining at -O1. use-after-scope-capture.cpp checks that the symbolization points to the line containing "return x;", but the combination of Windows/inlining/lambdas makes the symbolization point to the line "f = [&x]() {". Mark the lambda as noinline since this test is not a test for symbolization. Reviewers: hans, dblaikie, vitalybuka Subscribers: #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D81193
18 lines
455 B
C++
18 lines
455 B
C++
// RUN: %clangxx_asan %stdcxx11 -O1 -fsanitize-address-use-after-scope %s -o %t && \
|
|
// RUN: not %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <functional>
|
|
|
|
int main() {
|
|
std::function<int()> f;
|
|
{
|
|
int x = 0;
|
|
f = [&x]() __attribute__((noinline)) {
|
|
return x; // BOOM
|
|
// CHECK: ERROR: AddressSanitizer: stack-use-after-scope
|
|
// CHECK: #0 0x{{.*}} in {{.*}}use-after-scope-capture.cpp:[[@LINE-2]]
|
|
};
|
|
}
|
|
return f(); // BOOM
|
|
}
|