-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir] Fix possible null dereference during error logging in EmitC #157456
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
Conversation
@llvm/pr-subscribers-mlir-emitc Author: Daniel Kuts (apach301) ChangesFixes #157452 Full diff: https://github.com/llvm/llvm-project/pull/157456.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
index a73470cdf76c5..6b88e2c525d07 100644
--- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
+++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
@@ -1320,7 +1320,11 @@ GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
// global has non-array type
auto lvalueType = dyn_cast<LValueType>(resultType);
- if (!lvalueType || lvalueType.getValueType() != globalType)
+ if (!lvalueType)
+ return emitOpError("on non-array type result type is not defined "
+ "for the global @")
+ << getName();
+ if (lvalueType.getValueType() != globalType)
return emitOpError("on non-array type expects result inner type ")
<< lvalueType.getValueType() << " to match type " << globalType
<< " of the global @" << getName();
|
@llvm/pr-subscribers-mlir Author: Daniel Kuts (apach301) ChangesFixes #157452 Full diff: https://github.com/llvm/llvm-project/pull/157456.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
index a73470cdf76c5..6b88e2c525d07 100644
--- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
+++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
@@ -1320,7 +1320,11 @@ GetGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
// global has non-array type
auto lvalueType = dyn_cast<LValueType>(resultType);
- if (!lvalueType || lvalueType.getValueType() != globalType)
+ if (!lvalueType)
+ return emitOpError("on non-array type result type is not defined "
+ "for the global @")
+ << getName();
+ if (lvalueType.getValueType() != globalType)
return emitOpError("on non-array type expects result inner type ")
<< lvalueType.getValueType() << " to match type " << globalType
<< " of the global @" << getName();
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you for the fix.
Can you rephrase the Message to something like "... expects result type to be an lvalue type for the global ...". I think that gives a better hint on what is expected for users not familiär with the details of the Operation.
That was a static analyzer report, so I don't know how to run this code or have any input data. But the problem is that code is syntactically inconsistent: there is a check that ensures |
Done |
6fa4e9e
to
335e5bc
Compare
335e5bc
to
1734346
Compare
Fixes #157452