Skip to content
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

8301580: Error recovery does not clear returnResult #12361

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Feb 1, 2023

Considering code like:

class C {
    void m
    {
        return;
    }
}

void m is wrapped in an erroneous tree (which is good), and if/when Attr is processing it in visitErroneous, it will create a new Env to attribute the erroneous part.

But, Attr will set a returnResult into the Env's info - and that info is shared with the outter Env, so there will be a returnResult set after visitErroneous. { return ; } is interpreted as an initializer, and there should be an error for the return there, but this error is missing, due to the set returnResult. This will then fail later in Flow with an exception:

$ javac -XDshould-stop.at=FLOW -XDdev /tmp/C.java
/tmp/C.java:3: error: '(' expected
    {
    ^
1 error
An exception has occurred in the compiler (19.0.1-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com/) after checking the Bug Database (http://bugs.java.com/) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.clearPendingExits(Flow.java:589)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$AliveAnalyzer.visitClassDef(Flow.java:544)
        ...

The proposal is to clear the returnResult from the Env's info.

This exception may affect JShell.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8301580: Error recovery does not clear returnResult

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12361/head:pull/12361
$ git checkout pull/12361

Update a local copy of the PR:
$ git checkout pull/12361
$ git pull https://git.openjdk.org/jdk pull/12361/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12361

View PR using the GUI difftool:
$ git pr show -t 12361

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12361.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 1, 2023

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 1, 2023
@openjdk
Copy link

openjdk bot commented Feb 1, 2023

@lahodaj The following labels will be automatically applied to this pull request:

  • compiler
  • kulla

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added compiler compiler-dev@openjdk.org kulla kulla-dev@openjdk.org labels Feb 1, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 1, 2023

Webrevs

@@ -5220,9 +5220,14 @@ public void visitAnnotatedType(JCAnnotatedType tree) {
public void visitErroneous(JCErroneous tree) {
if (tree.errs != null) {
Env<AttrContext> errEnv = env.dup(env.tree);
Copy link
Contributor

Choose a reason for hiding this comment

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

question: shouldn't we do: env.dup(node, env.info.dup()); instead, that way both env's won't share the info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was a little bit on the fence on this, as some code, like Attr.attribClass stores and re-sets the result, while other dupes the info. Let's dupe the info then. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I didn't realize of the other pattern, not duping the info, we should probably standardize what we do at some point

Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

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

looks good

@openjdk
Copy link

openjdk bot commented Feb 3, 2023

@lahodaj 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:

8301580: Error recovery does not clear returnResult

Reviewed-by: vromero

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 107 new commits pushed to the master branch:

  • e7247b1: 8298872: Update CheckStatus.java for changes to TLS implementation
  • 20579e4: 8299994: java/security/Policy/Root/Root.java fails when home directory is read-only
  • 5962226: 8300891: Deprecate for removal javax.swing.plaf.synth.SynthLookAndFeel.load(URL url)
  • 8b70256: 8301787: java/net/httpclient/SpecialHeadersTest failing after JDK-8301306
  • bccd55b: 8300295: [AIX] TestDaemonDestroy fails due to !is_primordial_thread assertion
  • 7435b27: 8301744: Remove unused includes of genOopClosures.hpp
  • 6f9106e: 8301306: java/net/httpclient/* fail with -Xcomp
  • ac9e046: 8301479: Replace NULL with nullptr in os/linux
  • cf68d9f: 8299155: C2: SubTypeCheckNode::verify() should not produce dependencies / oop pool entries
  • 11804b2: 8301050: Detect Xen Virtualization on Linux aarch64
  • ... and 97 more: https://git.openjdk.org/jdk/compare/c2ebd179388cac5d6e10f98aab9a7ea909f8bc6b...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 3, 2023
@lahodaj
Copy link
Contributor Author

lahodaj commented Feb 6, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

Going to push as commit 522fa13.
Since your change was applied there have been 122 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 6, 2023
@openjdk openjdk bot closed this Feb 6, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 6, 2023
@openjdk
Copy link

openjdk bot commented Feb 6, 2023

@lahodaj Pushed as commit 522fa13.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated kulla kulla-dev@openjdk.org
2 participants