RFR: 7903526: jtreg should handle exceptions thrown by virtual threads

Alan Bateman alanb at openjdk.org
Sat Oct 28 16:45:58 UTC 2023


On Tue, 10 Oct 2023 20:49:42 GMT, Leonid Mesnik <lmesnik at openjdk.org> wrote:

> Currently, jtreg executes a test in MainThreadGroup and checks uncaught exceptions for this group. So it handles all exceptions if the test doesn't create new thread groups.
> However, the virtual threads don't belong to MainThreadGroup and jtreg silently ignores all exceptions thrown by virtual threads.
> 
> The testing shows that we have already some problems in jdk/jdk and probably in UR releases. There are 13 test failures in tier1 and several tens in the execution of tests that use secutiry-manager and run with a virtual thread.
> 
> It wonder if it makes sense to have this check conditional using some java property and start fixing tests after jtreg is release and smoothly switch execution to the new version.

src/share/classes/com/sun/javatest/regtest/agent/MainActionHelper.java line 264:

> 262:                     && (error == null)) {
> 263:                 if (avmr.t == null) {
> 264:                     error = tg.uncaughtThrowable != null ? tg.uncaughtThrowable : globalUncaughtThrowable;

Are you missing synchronisation here? The VM-side UHE is set while holding the lock for the MainActionHelper instance whereas help you read without any synchronisation. If you make globalUncaughtThrowable volatile then it would be okay, meaning keep the synchronisation in the setter code, read from elsewhere without synchronisation.

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

PR Review Comment: https://git.openjdk.org/jtreg/pull/172#discussion_r1375280991


More information about the jtreg-dev mailing list