RFR: JDK-8292351: tty should always live

Thomas Stuefe stuefe at openjdk.org
Wed Aug 17 13:33:09 UTC 2022


On Wed, 17 Aug 2022 12:42:09 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > I only chose stdout to keep with the standard behavior of VM output.
> 
> And therein lies the problem of using stderr. How is this going to work with the flags that switch the VM output between stdout and stderr? Will it make any sense? And how it it going to be when the pre-init output goes to stderr, the regular goes to stdout, and then the termination goes to stderr again?
> 
> Really you are introducing a new logging destination only used pre-init and post-termination, but pretending it is the regular "tty" output when it isn't.

Yes. Because that is still better than what we do now. We crash. Before VM init, depending on whether a signal handler is active (custom launchers) with more or less fanfare. In the standard java launcher accessing tty before VM init leads to a single taciturn "Code dumped", which will go to stderr. Or directly to tty, depending on the system.

VMs that crash without a trace are a plague, especially in cloud scenarios where you have little to none diagnostic possibilities.

Printing to stderr is better than crashing. It is the expected behavior. It is what the C-Runtime and other system libraries do when encountering errors. If we corrupt the stack, for instance.

I cannot think of a single scenario where a vanishing or core-ing JVM is better than one that prints its message to stderr.

And yes, I create a second "tty", since that allows us to use the same stream object all over the VM while being oblivious about the Life stage the VM is in. The alternative would be to create a second tty, "tty_safe" or similar, and sprinkle conditional coding all over the code base. That is not feasible, apart from being hideous.

> 
> I think the better solution is to expand the usability window of the tty by deferring its shutdown as long as possible. 

> There should be minimal stuff happening before argument processing so not really anything to "log" at that time.

Plain not true. At least not for me, otherwise I would not have bothered with this RFR. I know that I have been in situations where I needed tty and did not use it since it was not yet initialized. NMT preinit system is just one example.

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

PR: https://git.openjdk.org/jdk/pull/9874


More information about the hotspot-dev mailing list