JDK-8284855 : Update needed to Cleaners added to jdk.crypto.cryptoki
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto:pkcs11
  • Affected Version: 19
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-04-13
  • Updated: 2022-04-22
  • Resolved: 2022-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b19Fixed
Related Reports
Relates :  
Relates :  
Description
The fix for JDK-8284368 replaced the finalizers in jdk.crypto.cryptoki with Cleaners.

However, there is a problem with the code changes. The Runnables registered with Cleaner refer to the object being registered ('this'). Meaning, the Cleaner mechanism will keep the objects reachable, preventing them from being cleaned and collected.

The JDK-8284368 change needs to be reworked to not reference 'this'.
Comments
Please update bug with applicable noreg label.
21-04-2022

Changeset: 60446746 Author: Xue-Lei Andrew Fan <xuelei@openjdk.org> Date: 2022-04-19 21:53:08 +0000 URL: https://git.openjdk.java.net/jdk/commit/60446746d41c3c80d9788a252b4a55afe44e1e7b
19-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8248 Date: 2022-04-14 18:06:10 +0000
14-04-2022

The issue should be addressed in JDK 19 as there is a risk of memory leak.
14-04-2022

For PKCS11, some native refactoring may be needed to allow it to disconnect() without keeping the PKCS11 object itself around.
13-04-2022