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

8312229: Crash involving yield, switch and anonymous classes #14930

Closed
wants to merge 1 commit into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jul 19, 2023

Consider code like:

    void test(Object o) {
        Runnable r = () -> {
            switch (o) {
                default -> {
                    Integer i = 42;
                    new Runnable() {
                        public void run() {
                            i.toString();
                        }
                    };
                }
            };
        };
    }

During LambdaToMethod, the i variable is seen as a local variable in the lambda, and re-written to a different variable inside the new lambda method. This is due to:

lambdaContext.addSymbol(tree.sym, LOCAL_VAR);

note the lambda frame is the topmost frame in this case.

But, if the code is altered to:

    void test(Object o) {
        Runnable r = () -> {
            var l = switch (o) {
                default -> {
                    Integer i = 42;
                    yield new Runnable() {
                        public void run() {
                            i.toString();
                        }
                    };
                }
            };
        };
    }

the topmost frame will not be the lambda frame, but rather a variable frame, so that the i variable is not seem as a lambda-local variable, and the translations eventually fail.

The proposed solution is to search for the lambda frame, ignoring intervening variable frames.


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-8312229: Crash involving yield, switch and anonymous classes (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14930

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 19, 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 Jul 19, 2023
@openjdk
Copy link

openjdk bot commented Jul 19, 2023

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

  • compiler

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

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Jul 19, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 19, 2023

Webrevs

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 sensible

@openjdk
Copy link

openjdk bot commented Jul 20, 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:

8312229: Crash involving yield, switch and anonymous classes

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

  • d7b9416: 8199149: Improve the exception message thrown by VarHandle of unsupported operation
  • 354c660: 8307185: pkcs11 native libraries make JNI calls into java code while holding GC lock
  • bae2247: 8308591: JLine as the default Console provider
  • b772e67: 8312395: Improve assertions in growableArray
  • 9fa944e: 8312019: Simplify and modernize java.util.BitSet.equals
  • fe41910: 8312459: Problem list java/awt/GraphicsDevice/DisplayModes/CycleDMImage.java for macOS
  • 8d29329: 8312320: Remove javax/rmi/ssl/SSLSocketParametersTest.sh from ProblemList
  • 94eb44b: 8312394: [linux] SIGSEGV if kernel was built without hugepage support
  • 3283328: 8311130: AArch64: Sync SVE related CPU features with VM options
  • a742767: 8312246: NPE when HSDB visits bad oop
  • ... and 35 more: https://git.openjdk.org/jdk/compare/b4dce0d62479c2494c02570a60319cb1a5932940...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 Jul 20, 2023
@lahodaj
Copy link
Contributor Author

lahodaj commented Jul 26, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jul 26, 2023

Going to push as commit 1f81e5b.
Since your change was applied there have been 91 commits pushed to the master branch:

  • e9daf4a: 8312916: Remove remaining usages of -Xdebug from test/hotspot/jtreg
  • 117f42d: 8312625: Test serviceability/dcmd/vm/TrimLibcHeapTest.java failed: RSS use increased
  • 2d05d35: 8312979: Fix assembler_aarch64.hpp after JDK-8311847
  • 78a8a99: 8312488: tools/jpackage/share/AppLauncherEnvTest.java fails with dynamically linked libstdc++
  • cb82c95: 8312415: Expand -Xlint:serial checks to enum constants with specialized class bodies
  • c6396dc: 8039165: [Doc] MessageFormat null locale generates NullPointerException
  • 36f3bae: 8312401: SymbolTable::do_add_if_needed hangs when called in InstanceKlass::add_initialization_error path with requesting length exceeds max_symbol_length
  • e554fde: 8311592: ECKeySizeParameterSpec causes too many exceptions on third party providers
  • 9606cbc: 8312524: [JVMCI] serviceability/dcmd/compiler/CompilerQueueTest.java fails
  • 91fe032: 8312818: Incorrect format specifier in a HttpClient log message
  • ... and 81 more: https://git.openjdk.org/jdk/compare/b4dce0d62479c2494c02570a60319cb1a5932940...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 26, 2023

@lahodaj Pushed as commit 1f81e5b.

💡 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
2 participants