-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8262368: wrong verifier message for bogus return type #2757
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
|
👋 Welcome back hseigel! A progress list of the required criteria for merging this PR into |
Webrevs
|
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.
Hi Harold,
Sorry I don't like the new messages. See below.
Thanks,
David
| if (return_type != VerificationType::bogus_type()) { | ||
| verify_error(ErrorContext::bad_code(bci), | ||
| "Method expects a return value"); | ||
| "Method descriptor has a non-void return type"); |
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.
I prefer the original text. The new text makes me have to think about what the actual problem is too much.
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 good with the fixed message. I agree that it took me an extra minute to understand the new messages, so the old ones (corrected) are fine. Nice simple test.
| * @test | ||
| * @bug 8262368 | ||
| * @summary Test that VerifyError messages are correct when return bytecodes | ||
| * andd method signatures do not match. |
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.
typo, andd
|
@hseigel This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 52 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
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.
You fixed the wrong one.
Cheers,
David
| verify_error(ErrorContext::bad_type(bci, | ||
| current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), | ||
| "Method expects a return value"); | ||
| "Method does not expect a return value"); |
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.
You've changed the wrong line. This one does expect a return value
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.
Hi David,
If a method's descriptor has a void return type, but the method contains a bytecode such as areturn, then I think the message "Method does not expect a return type" is correct. Perhaps the word 'expect' is ambiguous? If so, then I think a more explicit message, similar to my original suggestion, should be used.
Harold
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.
Okay I see now the original bug report was incorrect and the referenced code is correct. But the above code is actually incorrect and now fixed.
| void ClassVerifier::verify_return_value( | ||
| VerificationType return_type, VerificationType type, u2 bci, | ||
| StackMapFrame* current_frame, TRAPS) { | ||
| if (return_type == VerificationType::bogus_type()) { |
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.
return_type is the type expected from the function, which here is void (I guess void == bogus_type, but ok).
So the message is correct.
|
Mailing list message from David Holmes on hotspot-runtime-dev: On 3/03/2021 1:26 am, Harold Seigel wrote:
First the bug report does not concern the line you changed! The bug "There is a typo in an error message in verifier.cpp on line 1678" 1675: case Bytecodes::_return : Here we have a plain _return bytecode, but the return-type is not void Now looking at the code you changed: if (return_type == VerificationType::bogus_type()) { We have found a void return and this is an error. That means a void Is there some weird double-negative logic being applied in all this that Cheers, |
|
Let's use javac to help us with the error message: |
|
Mailing list message from David Holmes on hotspot-runtime-dev: Hi Coleen, On 3/03/2021 12:50 pm, Coleen Phillimore wrote:
Thank you! I see now where I was reading things in an inverted sense: 1675: case Bytecodes::_return : Here we have a plain "return" but the method's return-type is not-void, As Harold discovered the true problem is with the other piece of code. Sorry for the confusion Harold! Thanks, |
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,
David
| verify_error(ErrorContext::bad_type(bci, | ||
| current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), | ||
| "Method expects a return value"); | ||
| "Method does not expect a return value"); |
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.
Okay I see now the original bug report was incorrect and the referenced code is correct. But the above code is actually incorrect and now fixed.
|
Thanks Coleen and David for the reviews! /integrate |
|
@hseigel Since your change was applied there have been 57 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 3d3eb5c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Please review this small change to fix some verifier error messages. If a method's descriptor has a void return signature, but contains a bytecode such as 'ireturn' or 'areturn'. then it will get a VerifyError exception with the message "Method descriptor has a void return type". Conversely, if a method's descriptor has a non-void return signature, but contains a 'return' bytecode then it will get a VerifyError exception with the message "Method descriptor has a non-void return type".
A sample error message looks like:
Error: Unable to initialize main class Hi
Caused by: java.lang.VerifyError: Method descriptor has a void return type
Exception Details:
Location:
Hi.noRet(I)V @1: ireturn
Reason:
Type integer (current frame, stack[0]) is not assignable to top (from method signature)
Current Frame:
bci: @1
flags: { }
locals: { integer }
stack: { integer }
Bytecode:
0000000: 08ac
The fix was tested with Mach5 tiers 1 and 2 on Linux, Mac OS, and Windows, tiers 3-5 on Linux x64. and the JCK Lang and VM tests on Linux x64.
Thanks, Harold
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2757/head:pull/2757$ git checkout pull/2757