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

David Holmes dholmes at openjdk.org
Thu Aug 11 02:31:21 UTC 2022


> 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.

David Holmes has updated the pull request incrementally with one additional commit since the last revision:

  Fixed `if` block indentation per Magnus's request

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/9803/files
  - new: https://git.openjdk.org/jdk/pull/9803/files/ad581740..ae305594

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=9803&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=9803&range=01-02

  Stats: 654 lines in 1 file changed: 0 ins; 0 del; 654 mod
  Patch: https://git.openjdk.org/jdk/pull/9803.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/9803/head:pull/9803

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



More information about the build-dev mailing list