-
Notifications
You must be signed in to change notification settings - Fork 5
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
Handling function pointer bounds #587
Conversation
@Machiry This change may stop John's particular example from crashing 3C, but I wouldn't be surprised if there are other places that 3C can dereference a null |
Ideally, all |
The total number of calls to |
I suggest we make this a warning; then if we notice incorrect behavior later, we'll see the warning as a possible cause. If we later make it a priority to fix problems of this nature, we could run whatever tests we want with the warning temporarily changed to an error (via a command-line flag or just editing the code on a branch). This case with |
I would rather not make this, |
I discussed the general unreliability of the bounds inference code with Mike. It's not clear to us what we should do about it now, so we propose to proceed with this specific fix and we can revisit the general problem later. John, if you have other thoughts about the general problem, let us know. Otherwise, we need to decide whether John or I will review the PR on its own merits. I imagine John knows more, but at some point it may make sense for me to start learning. |
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.
Looks fine. Mostly suggestion for comment improvements.
if (ParmVarDecl *PD = dyn_cast<ParmVarDecl>(D)) { | ||
if (PD->getParentFunctionOrMethod()) | ||
if (PD->getParentFunctionOrMethod()) { |
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.
Shouldn't this always be true now? isValidBoundVariable
returns false when getParentFunctionOrMethod
is null, so execution would never reach here.
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.
Actually, No. isValidBoundVariable
does not check for getParentFunctionOrMethod
.
bool AVarBoundsInfo::isValidBoundVariable(clang::Decl *D) {
// All parameters, return, and field values are valid bound variables.
if (D && (isa<ParmVarDecl>(D) || isa<FunctionDecl>(D) || isa<FieldDecl>(D)))
return true;
// For VarDecls, check if these are are not dummy and have a name.
if (auto *VD = dyn_cast_or_null<VarDecl>(D))
return !VD->getNameAsString().empty();
return false;
}
Co-authored-by: John Kastner <[email protected]>
Co-authored-by: John Kastner <[email protected]>
Co-authored-by: John Kastner <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This should be fine to merge.
Issue: #575