RFR: 8313202: MutexLocker should disallow null Mutexes [v3]

Aleksey Shipilev shade at openjdk.org
Tue Aug 1 17:58:44 UTC 2023


On Tue, 1 Aug 2023 17:48:04 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:
>> 
>>  - Accept one more potentially nullptr mutex
>>  - Merge branch 'master' into JDK-8313202-mutexlocker-nulls
>>  - Replace ReentrantMutexLocker with ConditionalMutexLocker
>>  - Workaround for JDK-8313210
>>  - Fixing CodeCache analytics
>>  - Initial work
>
> src/hotspot/share/oops/instanceKlass.cpp line 3409:
> 
>> 3407: bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
>> 3408:   // This is a short non-blocking critical region, so the no safepoint check is ok.
>> 3409:   ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag);
> 
> This is sort of an unfortunate pattern.  It's too bad we don't have a better name for this MutexLocker, but on the other hand maybe this should be fixed to take the lock at a higher place in this call stack and these conditional mutexLockers should be asserts.

Yes, it might even be _didactically correct_ to make sure that questionable uses are clunky to write :)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15043#discussion_r1280970891


More information about the hotspot-dev mailing list