[lworld] RFR: 8303416: [lworld] Fix JVM crash at Unsafe_FinishPrivateBuffer [v2]

Xiaohong Gong xgong at openjdk.org
Fri Mar 3 08:37:39 UTC 2023


> When calling Unsafe.finishPrivateBuffer(), JVM crashes with following
>  assertion failure:
> 
> 
>  Internal Error (/mnt/local/code/valhalla/src/hotspot/share/prims/unsafe.cpp:388), pid=29517, tid=29518
>   assert(v->mark().is_larval_state()) failed: must be a larval value
> 
>  JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-git-05e4d0dba)
>  Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-git-05e4d0dba, mixed mode, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
>  Problematic frame:
>  V  [[libjvm.so](http://libjvm.so/)+0x1a92a64]  Unsafe_FinishPrivateBuffer+0xc0
> 
> The assertion is used to check whether the input value is in larval
>  state. Usually this method is called after `Unsafe.makePrivateBuffer()`,
>  which will create a new oop and set it to larval state. If everything
>  works fine, the above assertion won't fail. But the issue happens if
>  all the fields of the input value object of `Unsafe.makePrivateBuffer()`
>  are the relative java default values (i.e. `0`). The root cause is the
>  C2 compiler will optimize the new buffered oop to the default oop for
>  such value object, and the larval state is missed during the optimization.
>  Marking the larval bit of the optimized oop can fix the issue.

Xiaohong Gong has updated the pull request incrementally with one additional commit since the last revision:

  Revert the larval bit setting change, and discard the default oop replacement for larval state oop

-------------

Changes:
  - all: https://git.openjdk.org/valhalla/pull/828/files
  - new: https://git.openjdk.org/valhalla/pull/828/files/d3820a09..0629b9bb

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=valhalla&pr=828&range=01
 - incr: https://webrevs.openjdk.org/?repo=valhalla&pr=828&range=00-01

  Stats: 33 lines in 2 files changed: 15 ins; 11 del; 7 mod
  Patch: https://git.openjdk.org/valhalla/pull/828.diff
  Fetch: git fetch https://git.openjdk.org/valhalla pull/828/head:pull/828

PR: https://git.openjdk.org/valhalla/pull/828



More information about the valhalla-dev mailing list