RFR: 8332084: Ensure JdkConsoleImpl.restoreEcho visibility in a shutdown hook [v3]
Stuart Marks
smarks at openjdk.org
Mon May 13 21:17:01 UTC 2024
On Mon, 13 May 2024 17:06:32 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> Making sure `restoreEcho` correctly reflects the state in the shutdown thread, which differs from the application's thread that issues the `readPassword()` method.
>
> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>
> Replaced another unused exception with _
Hm, I don't think we want to add any synchronized blocks within a shutdown hook. If a thread is blocked reading from the console, it will hold readLock; if the JVM is then shut down using a signal, it will run shutdown hooks, and this hook will block awaiting readLock. This can deadlock the shutdown completely.
To ensure proper memory visibility, maybe consider making `restoreEcho` be volatile.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19184#issuecomment-2108811013
More information about the core-libs-dev
mailing list