8261837: SIGSEGV in ciVirtualCallTypeData::translate_from#16750
8261837: SIGSEGV in ciVirtualCallTypeData::translate_from#16750dean-long wants to merge 8 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back dlong! A progress list of the required criteria for merging this PR into |
|
@dean-long The following label will be automatically applied to this pull request:
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. |
Webrevs
|
|
Moved to Draft. There is no rscratch1 register on 32-bit x86. |
| xorptr(obj, rscratch1); // get back original value before XOR | ||
| xorptr(obj, mdo_addr); |
There was a problem hiding this comment.
Was it bug here originally? We had 2 xors (including this) and now 3 for obj.
There was a problem hiding this comment.
Yes, there was a bug here originally. obj could have contained a bad value. The code wants to store the Klass* from load_klass with the low TypeEntries::null_seen bit from mdo_addr ORed in. However, because the low bits of the Klass* are 0, XOR was used to both OR the low bits and SET the high bits, assuming the high bits from mdo_addr are 0.
The problem comes from assuming the mdo_addr memory value is stable and reloading the value from memory to compare against 0 and TypeEntries::null_seen. A transient 0 can appear because of non-atomic updates like this:
orptr(mdo_addr, TypeEntries::null_seen);
An alternative fix would be to get rid of the races and use atomic compare-and-swap to write new values.
The new 2nd XOR is an optimization, instead of calling load_klass() again, or saving the original obj value somewhere else. The 3nd XOR is a repeat of the 1st XOR. I don't think this slow path retry is that useful, and not all platforms do it, but I left it in because I wanted to minimize changes.
|
@vnkozlov, you might want to wait until the 32-bit x86 code is fixed before reviewing. If I can't find an extra temp register to use, I'll need to make more significant changes. |
|
pseudo-code of the bug: |
veresov
left a comment
There was a problem hiding this comment.
Great find! Thank you for getting to the bottom of it!
|
Thanks @veresov. I had to push a different fix for x86 because of a lack of scratch registers. Please take another look. |
|
@dean-long 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 99 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 |
|
/label hotspot-runtime |
|
@dean-long |
|
Can I get a RISC-V developer to test this for me, please? |
|
@dean-long : Hi Dean, thanks for adding handling for riscv. |
|
/contributor @RealFYang |
|
Thanks @RealFYang |
|
@dean-long Syntax:
User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address. |
|
/contributor add fyang |
|
@dean-long |
vnkozlov
left a comment
There was a problem hiding this comment.
Latest changes looks good.
|
/integrate |
|
Going to push as commit 1bb250c.
Your commit was automatically rebased without conflicts. |
|
@dean-long Pushed as commit 1bb250c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
| __ jcc(Assembler::notZero, next); // already set | ||
| #endif | ||
| // atomic update to prevent overwriting Klass* with 0 | ||
| __ lock(); |
There was a problem hiding this comment.
One thing I'm curious about: why is the locked update only here on x86, and not in any other port?
Type profiling code based on the x86 implementation uses XOR to check if the MDO value matches the klass, then later stores that XORed value into the MDO if the MDO value was 0. However, there is a race here if we reload the MDO value to check for 0, resulting in storing OBJ_KLASS XOR MDO_KLASS back to the MDO.
I took a stab at riscv, but I don't have a way to test it.
Progress
Issue
Reviewers
Contributors
<fyang@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16750/head:pull/16750$ git checkout pull/16750Update a local copy of the PR:
$ git checkout pull/16750$ git pull https://git.openjdk.org/jdk.git pull/16750/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16750View PR using the GUI difftool:
$ git pr show -t 16750Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16750.diff
Webrev
Link to Webrev Comment