-
Notifications
You must be signed in to change notification settings - Fork 277
C entry point generator: no unconditional conversion to pointer type #6976
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
@@ -248,7 +248,10 @@ bool generate_ansi_c_start_function( | |||
{ | |||
// ok | |||
} | |||
else if(parameters.size()==2 || parameters.size()==3) | |||
else if( | |||
parameters.size() >= 2 && parameters[1].type().id() == ID_pointer && |
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.
Did you mean parameters[0]
?
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.
No, parameters[0]
is what we'd expect to be argc
if I' not mistaken?
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 looks wrong because the regression test has (char *argv, int argc)
but the CBMC code is expecting/assuming the parameters in the other order. Is there a place where the code rewrites/forces the order, or is this actually entirely up to the code being sent to CBMC? If the former, a comment would clarify this, if the latter, then this code makes assumptions that may be wrong.
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.
The one place that enforces the order is the C standard (and any related architecture descriptions). The user, however, may supply arbitrary (syntactically valid) C code, even one that does not respect the calling conventions set out in the C standard. If the user does supply such code (as is done in the accompanying regression test), then we can only tell them that they got it wrong, which is what we do via the error message in the else
branch of this code. The change being proposed here should make sure that we do end up in this else
branch.
Does this address your concern? Should I still be making changes to the implementation? Should I perhaps add the above as a comment?
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.
Yes, I'm happy to approve. The detail in your response might be nice to have in the comments though since this is not immediately clear.
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.
Comment added to the code.
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.
The comment is very helpful.
Codecov ReportBase: 77.88% // Head: 77.88% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #6976 +/- ##
========================================
Coverage 77.88% 77.88%
========================================
Files 1576 1576
Lines 181856 181859 +3
========================================
+ Hits 141645 141648 +3
Misses 40211 40211
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
52307ed
to
b752c2d
Compare
@@ -248,7 +248,10 @@ bool generate_ansi_c_start_function( | |||
{ | |||
// ok | |||
} | |||
else if(parameters.size()==2 || parameters.size()==3) | |||
else if( | |||
parameters.size() >= 2 && parameters[1].type().id() == ID_pointer && |
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.
Yes, I'm happy to approve. The detail in your response might be nice to have in the comments though since this is not immediately clear.
b752c2d
to
e86af02
Compare
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 looks like a great solution. Only suggestion would be to add more detail to the regression test about what the test is aiming to achieve.
@@ -248,7 +248,10 @@ bool generate_ansi_c_start_function( | |||
{ | |||
// ok | |||
} | |||
else if(parameters.size()==2 || parameters.size()==3) | |||
else if( | |||
parameters.size() >= 2 && parameters[1].type().id() == ID_pointer && |
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.
The comment is very helpful.
^EXIT=(64|1)$ | ||
^SIGNAL=0$ | ||
-- | ||
Invariant check failed |
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.
Can we add a description of what the test is trying to achieve? Maybe something like:
In this test, we detect a non-standard C entry point and gracefully exit with a message to the user.
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.
Thank you, done!
Do not try to create a pointer_typet when the type might not actually be a pointer type. This was triggerable by syntactically well-formed C input and should instead be handled by a user-facing error message. Fixes: diffblue#6975
e86af02
to
6f96674
Compare
Do not try to create a pointer_typet when the type might not actually be
a pointer type. This was triggerable by syntactically well-formed C
input and should instead be handled by a user-facing error message.
Fixes: #6975