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

8333177: Invalid value used for enum Cell in ciTypeFlow::get_start_state #19520

Closed
wants to merge 2 commits into from

Conversation

TobiHartmann
Copy link
Member

@TobiHartmann TobiHartmann commented Jun 3, 2024

Ubsan detected undefined behavior in ciTypeFlow::get_start_state because an invalid value of 4294967295 is assigned to enum Cell:

enum Cell {
Cell_0, Cell_max = INT_MAX
};

The problem is that if the C++ compiler decides to encode Cell with an unsigned int, casting a negative integer value will lead to an underflow and therefore a value > Cell_max = INT_MAX. Here, state->tos() returns a value < 0:

Cell cell = state->next_cell(state->tos());

which is casted to a Cell:

static Cell next_cell(Cell c) { return (Cell)(((int)c) + 1); }

I simply re-wrote the code to not require a negative Cell value to iterate over the locals and setting them to bottom type.

Thanks,
Tobias


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-8333177: Invalid value used for enum Cell in ciTypeFlow::get_start_state (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19520

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 3, 2024

👋 Welcome back thartmann! 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
Copy link

openjdk bot commented Jun 3, 2024

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

8333177: Invalid value used for enum Cell in ciTypeFlow::get_start_state

Reviewed-by: kvn, chagedorn

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

  • 64bbae7: 8333394: C2: assert(bol->is_Opaque4() || bol->is_OpaqueInitializedAssertionPredicate()) failed: Opaque node of non-null-check or of Initialized Assertion Predicate
  • c7495fb: 8333444: Parallel: Inline PSParallelCompact::mark_obj
  • 454660d: 8332900: RISC-V: refactor nativeInst_riscv.cpp and macroAssembler_riscv.cpp
  • 67d6f3c: 8332905: C2 SuperWord: bad AD file, with RotateRightV and first operand not a pack
  • ca30726: 8332866: Crash in ImageIO JPEG decoding when MEM_STATS in enabled
  • 29e10e4: 8332547: Unloaded signature classes in DirectMethodHandles
  • c7d2a5c: 8314070: javax.print: Support IPP output-bin attribute extension
  • d230b30: 8333398: Uncomment the commented test in test/jdk/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
  • 1512011: 8332123: [nmt] Move mallocLimit code to the nmt subdir
  • 6dac8d6: 8332424: Update IANA Language Subtag Registry to Version 2024-05-16
  • ... and 6 more: https://git.openjdk.org/jdk/compare/f0bffbce35bb06e724857e8651dd429c4f9df284...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 rfr Pull request is ready for review label Jun 3, 2024
@openjdk
Copy link

openjdk bot commented Jun 3, 2024

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

  • hotspot-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 hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 3, 2024
@mlbridge
Copy link

mlbridge bot commented Jun 3, 2024

Webrevs

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

This looks correct.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 3, 2024
@TobiHartmann
Copy link
Member Author

Thanks for the review, Vladimir!

Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
@TobiHartmann
Copy link
Member Author

Thanks for the review Christian. Your suggestion makes sense!

Copy link
Member

@chhagedorn chhagedorn 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, thanks for the update!

@TobiHartmann
Copy link
Member Author

Thanks for the review!

@TobiHartmann
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 6, 2024

Going to push as commit 6f690a5.
Since your change was applied there have been 61 commits pushed to the master branch:

  • b351b5f: 8331736: C2: Live Node limit exceeded limit after JDK-8316991
  • b3f540d: 8332921: Ctrl+C does not call shutdown hooks after JLine upgrade
  • 3089412: 8326716: JVMTI spec: clarify what nullptr means for C/C++ developers
  • ca93907: 8256828: ostream::print_cr() truncates buffer in copy-through case
  • 60ea17e: 8311177: Switching to interpreter only mode in carrier thread can lead to crashes
  • 7564949: 8291643: Consider omitting type annotations from type error diagnostics
  • 4c09d9f: 8332119: Incorrect IllegalArgumentException for C2 compiled permute kernel
  • f7dbb98: 8333086: Using Console.println is unnecessarily slow due to JLine initalization
  • 9b3694c: 8319822: Use a linear-time algorithm for assert_different_registers()
  • f73922b: 8333235: vmTestbase/nsk/jdb/kill/kill001/kill001.java fails with C1
  • ... and 51 more: https://git.openjdk.org/jdk/compare/f0bffbce35bb06e724857e8651dd429c4f9df284...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 6, 2024

@TobiHartmann Pushed as commit 6f690a5.

💡 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
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants