Integrated: 8328698: oopDesc::klass_raw() decodes without a null check
Stefan Karlsson
stefank at openjdk.org
Mon Apr 8 09:32:14 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.
This pull request has now been integrated.
Changeset: 6f087cbc
Author: Stefan Karlsson <stefank at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/6f087cbcd5c8c91eb104c6e4297f485dd1a82229
Stats: 93 lines in 10 files changed: 42 ins; 34 del; 17 mod
8328698: oopDesc::klass_raw() decodes without a null check
Reviewed-by: ayang, tschatzl
-------------
PR: https://git.openjdk.org/jdk/pull/18597
More information about the hotspot-dev
mailing list