-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[static analyser][StackAddrEscapeChecker] crash with std::function capturing a dangling reference #66221
Comments
Crash is in:
|
Crash is in:
We expect that we get VarRegion here but we geting CXXTempObjectRegion. And then we crash on getDecl() call that is virtual. |
@llvm/issue-subscribers-clang-static-analyzer
When trying to analyze the following code with clang-tidy, I get a crash:
//minimal.cpp
#include <functional>
auto f() -> std::function<int()> {
int v;
auto c = [&v]() {
return v;
};
return c;
}
auto main() -> int { return f()(); } The function Command clang-tidy-16 minimal.cpp -- -std=c++20 Crash report:
$ clang-tidy-16 --version
Debian LLVM version 16.0.6
Optimized build. But the crash happens with clang-tidy 16, 17, 18, as well as the system 14.0.6 (inside a debian:latest docker) and the system 15.0.7 (on a Ubuntu 23.04 machine). |
@PiotrZSL Could you post the preprocessed source for the reproducer? |
@steakhal it's the one in first post, i tested this on ubuntu. |
When trying to analyze the following code with clang-tidy, I get a crash:
The function
f
returns astd::function
wrapping a lambda with a dangling reference in its capture. The crash doesn't happen if I return a lambda instead of astd::function
, nor if I capture by value.Command
Crash report:
But the crash happens with clang-tidy 16, 17, 18, as well as the system 14.0.6 (inside a debian:latest docker) and the system 15.0.7 (on a Ubuntu 23.04 machine).
The text was updated successfully, but these errors were encountered: