-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NativeDigest context free via Cleaner API #191
Conversation
@pshipton @DanHeidinga @keithc-ca still testing the changes locally. If possible, would like to get the review cycle started. See eclipse-openj9/openj9#5611 and eclipse-openj9/openj9#4530 for the actual error reports. Also note that I can't be certain this PR will fix those issues as I'm unable to reproduce the error locally. However, looking at the code at Java_jdk_crypto_jniprovider_NativeCrypto_DigestUpdate which has extensive error checking likely the crash occurs here: so I'm assuming context is de-allocated too early which is why the crash happens in the finalizer of |
This won't clean if new Digest's aren't being created. Ideally https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ref/Cleaner.html should be used. |
You may want to reuse the common cleaner accessible via |
@pshipton @keithc-ca is this also available for jdk8? |
Yes, in Java 8 there is |
@ashbm5 Are you adapting this PR in light of Keith & Peter's comments on using sun.misc.Cleaner? |
@DanHeidinga I'm a bit concerned about the performance impact of using sun.misc.Cleaner since it requires a background thread so I'm also evaluating the perf. impact of this approach. Also try different ways of resolving this issue - perhaps by buffering input data before sending to OpenSSL |
Look at how Cleaner is used in other places. MutableCallSite is one example: The Cleaner is processed immediately when it's being enqueued. No extra thread is required. |
@pshipton @keithc-ca @DanHeidinga updated the PR with using the Cleaner API code. I did the relevant performance testing and found out that there is some impact when constant digest objects are being created and released when compared to finalizer but only slightly so while hopefully fixing the reported issues. with optimized code that doesn't constantly create new digest objects, there is no performance impact. |
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/sun/security/provider/SunEntries.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
e5c99dd
to
9fc5b66
Compare
@keithc-ca updated, please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the merge conflict. Please also rebase (on the current head of the openj9 branch) and squash.
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Outdated
Show resolved
Hide resolved
176dd61
to
e1b0150
Compare
@keithc-ca updated, please review |
closed/src/java.base/share/classes/sun/security/provider/NativeDigest.java
Show resolved
Hide resolved
Signed-off-by: Alon Shalev Housfater <alonsh@ca.ibm.com>
Jenkins test all,sanity,extended zlinux jdk11 |
The build and both test jobs were successful, but something strange happened to the 'parallel' part of the test job: merging under the assumption that the strangeness is irrelevant. |
Correct encoding of META-INF/services config files - javac tooling fix
due to issues such as eclipse-openj9/openj9#5611 removed the native context de-allocation via a finalizer. Introduced the use of PhantomReferences to control when the native digest context can be de-allocated.
The cleanup stage happens when the reference array is fully used, at which point there is an attempted clean-up by examining the ReferenceQueue which will de-allocate the native contexts and also free up space in the reference array.
Signed-off-by: Alon Shalev Housfater alonsh@ca.ibm.com