RFR: 8290732: JNI DestroyJavaVM can start shutdown when one non-daemon thread remains

Magnus Ihse Bursie ihse at openjdk.org
Tue Aug 9 12:47:21 UTC 2022


On Tue, 9 Aug 2022 06:10:40 GMT, David Holmes <dholmes at openjdk.org> wrote:

> Please review this fix for a problem discovered by @stuart-marks in the course of examining the VM shutdown behaviour. The VM code assumed that only unattached threads called JNI's DestroyJavaVM and so they were always attached as non-daemon threads. But it is perfectly valid to call DestroyJavaVM from an already attached thread, which could be a daemon. The fix simply checks whether the caller is a daemon or not and adjusts the expected count of active threads to see. There is also an adjustment to the thread termination logic to also notify at the right time.
> 
> Thanks to @stuart-marks for the reproducer in JBS - the longest part of this by many hours was converting the test over the jtreg. :)
> 
> Testing:
>  - the new test on all core platforms
>  - tiers 1-3
> Thanks.

make/test/JtregNativeHotspot.gmk line 869:

> 867:     BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libAsyncGetCallTraceTest := -ldl
> 868: else
> 869:     BUILD_HOTSPOT_JTREG_EXCLUDE += libtest-rw.c libtest-rwx.c \

Actually this line was correctly indented, and all other incorrectly... If you can be bothered to fix it, please make sure there is just a two space indentation in the "if" block.

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

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



More information about the build-dev mailing list