RFR: 8328698: oopDesc::klass_raw() decodes without a null check

Thomas Schatzl tschatzl at openjdk.org
Fri Apr 5 10:30:00 UTC 2024


On Wed, 3 Apr 2024 09:27:16 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> The oopDesc::klass_raw() function is used when the caller wants to skip asserts. Unfortunately, it skips the the check to see if the narrow klass is zero, which could lead to an incorrect Klass* being returned. This patch fixes this.
> 
> In addition to this, I'm trying to make the code a bit clearer, so the patch also contains changes for the following:
> 
> * The word raw has various different meaning in the context of oops and klasses. So, what does it mean in this context? Does it mean "read the klass pointer value without decoding it"? Or does it mean "decode the klass pointer value without any asserts"? I would like to propose that we use a name that describes that this function is used to skip performing various asserts.
> 
> * I replaced the one usage of load_klass_raw with a call to klass_raw() instead.
> 
> * I restructured the `is_oop_safe` so that we perform the null-check first. Note that `oopDesc::is_oop` performs its own verification of the klass pointer, so if we want extra klass verification in `is_oop_safe` we need to do it before calling the `is_oop` check. 
> 
> * I also renamed the _raw functions inside the CompressedKlassPointers klass and moved private functions.
> 
> Tell me if you think some of these should be split up into separate RFEs.
> 
> Tested with tier1-3.

Marked as reviewed by tschatzl (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/18597#pullrequestreview-1982644482


More information about the hotspot-dev mailing list