Integrated: 8297389: resexhausted003 fails with assert(!thread->owns_locks()) failed: must release all locks when leaving VM
Tobias Hartmann
thartmann at openjdk.org
Thu Dec 1 08:53:15 UTC 2022
On Wed, 23 Nov 2022 11:56:45 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
> `Method::build_profiling_method_data` acquires the `MethodData_lock` when initializing `Method::_method_data` to prevent multiple allocations by different threads. The problem is that when metaspace allocation fails and `JvmtiExport::should_post_resource_exhausted()` is set, we assert during the `ThreadToNativeFromVM` transition in JVMTI code.
>
> Since concurrent initialization is a rare event, I suggest to get rid of the lock and perform the initialization with a `cmpxchg`, similar to how method counters are initialized:
> https://github.com/openjdk/jdk/blob/f4b5065c37e86f4b2ca26da6ce678febe4a52950/src/hotspot/share/oops/method.cpp#L644-L646
>
> Since [current code](https://github.com/openjdk/jdk/blob/f4b5065c37e86f4b2ca26da6ce678febe4a52950/src/hotspot/share/oops/method.inline.hpp#L41-L46) in `Method::set_method_data` uses a `Atomic::release_store`, I added a `OrderAccess::release()`.
>
> Thanks,
> Tobias
This pull request has now been integrated.
Changeset: 9f24a6f4
Author: Tobias Hartmann <thartmann at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/9f24a6f43c6a5e1fa92275e0a87af4f1f0603ba3
Stats: 39 lines in 5 files changed: 4 ins; 15 del; 20 mod
8297389: resexhausted003 fails with assert(!thread->owns_locks()) failed: must release all locks when leaving VM
Reviewed-by: dholmes, rrich, dlong
-------------
PR: https://git.openjdk.org/jdk/pull/11316
More information about the hotspot-dev
mailing list