RFR: 8367725: Incorrect reading of oop in SuspendResumeManager::suspend while thread is blocked [v9]

David Holmes dholmes at openjdk.org
Wed Sep 17 20:44:50 UTC 2025


On Wed, 17 Sep 2025 14:56:47 GMT, Leonid Mesnik <lmesnik at openjdk.org> wrote:

>> The
>> `SuspendResumeManager::suspend(bool register_vthread_SR)`
>> has an issue while suspend current virtual thread. The suspend tries to access vthread oop field to read vthread id after thread is blocked. 
>> 
>> Seems, that this case is not used by our debugger and was not covered by tests. I found it using jtreg test thread virtual factory plugin. I updated existing test to reproduce this problem. The easiest way is to suspend current virtual thread using plain SuspendThread. 
>> 
>> The fix added some "asymmetry"  in suspend/resume mechanism which is required because self-suspend doesn't have resume counterpart.
>
> Leonid Mesnik has updated the pull request incrementally with one additional commit since the last revision:
> 
>   updated after David's feedback

src/hotspot/share/runtime/suspendResumeManager.hpp line 63:

> 61: 
> 62:   // The specific 'set_suspended' implementation for self suspend.
> 63:   void set_suspended_with_id(int64_t id, bool register_vthread_SR);

Suggestion:

  // Sets the suspended state to `to`, applying to vthreads if `register_vthread_SR` is true.
  void set_suspended(bool to, bool register_vthread_SR);

  // Sets the suspended state to true, applying to vthreads if `register_vthread_SR` is true.
  // Applied to the thread with the given `id` and used when we can't extract the thread oop safely.
  void set_suspended_with_id(int64_t id, bool register_vthread_SR);

These comments are far from perfect as it is actually hard to explain exactly what `thread` is being operated on - if any!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27317#discussion_r2356737184


More information about the serviceability-dev mailing list