RFR: 8356173: Remove ThreadCritical [v2]
David Holmes
dholmes at openjdk.org
Sun May 11 12:40:56 UTC 2025
On Sat, 10 May 2025 03:28:03 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> You're right, it doesn't need to be volatile. I want the recursion checking to be platform independent for this lock, and not affect the other PlatformMutex/Monitors which are outside the scope of this change and hopefully are what we want already.
>
> But the recursion checking isn't platform independent. For POSIX it does nothing useful and is just useless
> clutter providing a false sense of security. I think it should be removed, and consider (as a separate thing)
> adding a recursion assert to the Windows implementation.
>
> And it should be debug-only there; there's no need to change the counter in a release build, since the
> check is an assert. It also doesn't need to be a counter; it could be a bool flag. But that's really about a
> future Windows-check. It just shouldn't be here.
I have to agree with Kim here, you can't implement a recursion check this way using a count, which has to be protected by the mutex itself. You would need to maintain an owner field, using the platform specific thread id type, which is checked before trying to acquire the mutex.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25072#discussion_r2083513230
More information about the hotspot-dev
mailing list