Skip to content

Fix a nullptr dereferencing in a FuncBufferizableOpInterfaceImpl.cpp::getCalledFunction #150518

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ static FuncOp getCalledFunction(CallOpInterface callOp,
const AnalysisState &state) {
auto &oneShotAnalysisState = static_cast<const OneShotAnalysisState &>(state);

if (auto *funcAnalysisState =
oneShotAnalysisState.getExtension<FuncAnalysisState>()) {
auto *funcAnalysisState =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really fix the issue?

auto *x = abc();
if (x != nullptr) foo();

is identical to

if (auto *x = abc()) foo();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right, I need to investigate the segfault more. Maybe this is not where the root cause is...

oneShotAnalysisState.getExtension<FuncAnalysisState>();
if (funcAnalysisState != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change to:

if (!funcAnalysisState)

And please add a test.

// Use the cached symbol tables.
return getCalledFunction(callOp, funcAnalysisState->symbolTables);
}
Expand Down