RFR: 8287637: Loom: Mismatched VirtualThread::state accessor

Aleksey Shipilev shade at openjdk.java.net
Thu Jun 2 18:18:40 UTC 2022


On Wed, 1 Jun 2022 07:57:34 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> Found this by reading the code, no test failure detected yet.
> 
> The field is defined on Java side as:
> 
> 
>     // virtual thread state, accessed by VM
>     private volatile int state;
> 
> 
> The field is defined on VM side as:
> 
> 
>   macro(_state_offset,                     k, "state",              int_signature,               false)
> 
> 
> And yet, it is accessed as `short`:
> 
> 
> u2 java_lang_VirtualThread::state(oop vthread) {
>   return vthread->short_field_acquire(_state_offset);
> }
> 
> 
> I think this is just asking for trouble on different endianness: the partial `u2` read from `int` field can read the "higher" two bytes, not the "lower" two bytes.
> 
> Additional testing:
>  - [x] Linux x86_64 fastdebug, `jdk_loom hotspot_loom`
>  - [x] Linux AArch64 fastdebug, `jdk_loom hotspot_loom`

Thanks, any other reviews?

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

PR: https://git.openjdk.java.net/jdk/pull/8967


More information about the hotspot-runtime-dev mailing list