RFR: 8318839: Update test thread factory to catch all exceptions [v2]

Alan Bateman alanb at openjdk.org
Fri Nov 3 07:14:05 UTC 2023


On Fri, 3 Nov 2023 05:43:38 GMT, David Holmes <dholmes at openjdk.org> wrote:

> I don't understand what this is trying to do. If any virtual thread has an uncaught exception then other virtual threads will throw it wrapped in a RuntimeException. But the first virtual thread that completes (normally or by throwing) will clear the default UEH that you set, so uncaught exceptions from other virtual threads won't do anything.
> 
> AFAICS setting the UEH for a virtual thread works fine, so why are you not setting a per-thread handler?

My reading is that it sets default UHE so it means that any thread (not just virtual threads) can potentially execute it. There will be tests that set a per thread UHE that doesn't delegate. There will also be platform threads in a jtreg ThreadGroup (a UHE) so the exceptions will be handled there (AFAIK, the jtreg TG/UGE does not delegate to the default UHE).

I think the patch is confusing because uncaughtException may be set several times, last one wins.  If virtual "main" completes without an exception then it looks at uncaughtException to see if an exception is recorded by another thread. It does wrap/propagate it as a runtime exception and I think the bit we aren't seeing is that this is handled by the real main on a platform thread in the jtreg TG.

If the virtual "main" completes with an exception (meaning task throws), then it resets the default UHE and exits with an uncaught handle. As with the runtime exception case, I think we aren't seeing this being handled by real main.

So I think it is working but confusing to read. I wonder if it might be better to just put the effort into helping CODETOOLS-7903526 instead of a workaround.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16369#discussion_r1381220891


More information about the core-libs-dev mailing list