RFR: JDK-8292351: tty should always live [v5]
David Holmes
dholmes at openjdk.org
Mon Aug 22 08:00:34 UTC 2022
On Sun, 21 Aug 2022 07:21:23 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> The default stream object tty is used in many places but its lifetime is limited. It gets born not-quite at the beginning of VM initialization and dies in DestroyVM. This leaves time windows before VM initialization and after VM cleanup where logging to tty crashes.
>>
>> This has been bugging me in the past, especially when wanting to use tty in code that runs very early (NMT preinit system, for example), and also causes problems for code that runs post-cleanup. Mostly this affects logging and error logging.
>>
>> tty should always be safe to write to, and that is trivial to do.
>
> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>
> Compromise
One minor issue below but otherwise this seems like a good compromise. Thanks.
src/hotspot/share/utilities/ostream.cpp line 432:
> 430: // The policy followed here is a compromise reached during review of JDK-8292351:
> 431: // - pre-init: we silently swallow all output. We won't see anything, but at least won't crash
> 432: // - post-exit: we write to a simple fdStream, but somewhat mimik the behavior of the real defaultStream
s/mimik/mimic/
src/hotspot/share/utilities/ostream.cpp line 982:
> 980: delete tty;
> 981: }
> 982: tty = DisplayVMOutputToStderr ? fdStream::stdout_stream() : fdStream::stderr_stream();
Shouldn't this be something like:
tmp = tty;
tty = ...
delete tmp;
-------------
PR: https://git.openjdk.org/jdk/pull/9874
More information about the hotspot-dev
mailing list