Skip to content
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

Add locking around AbstractSessionContext JNI. #1154

Merged
merged 2 commits into from
Aug 6, 2023

Commits on Aug 4, 2023

  1. Add locking around AbstractSessionContext JNI.

    We don't have a definitive root cause for google#1131 but it seems like either use-after-free (e.g. finalizer ordering) or concurrency issue, so:
    1. Make the native pointer private and move all accesses into AbstractSessionContext
    2. Zero it out on finalisation
    3. Add locking. Note we only need a read lock for the sslNew() path as this is thread safe and doesn't modify the native SSL_CTX aside from atomic refcounts.
    
    The above change is broadly equivalent to turning the native pointer into a NativeRef, which would mean its finalizer shouldn't run until after the AbstractSessionContext object is unreachable, but (currently) NativeRefs don't zero out the native address on finalization.
    prbprbprb committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    3be111f View commit details
    Browse the repository at this point in the history
  2. Reword comment.

    prbprbprb committed Aug 4, 2023
    Configuration menu
    Copy the full SHA
    3a15f89 View commit details
    Browse the repository at this point in the history