-
Notifications
You must be signed in to change notification settings - Fork 5.3k
hold reference to SslContextHandle to prevent crashes #73972
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
Conversation
|
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsThis is speculative fix for #73621 and #69125. The theory is like this: This change grabs reference on The crashes are happening daily in CI so we should know in next few days if this fixes the crashes.
|
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OpenSsl.cs
Outdated
Show resolved
Hide resolved
…aphy.Native/Interop.OpenSsl.cs Co-authored-by: Stephen Toub <[email protected]>
|
@wfurt I fixed the milestone -- the PR was merged after 7.0 fork, so it won't be part of 7.0. |
|
/backport to release/7.0-rc1 |
1 similar comment
|
/backport to release/7.0-rc1 |
|
Started backporting to release/7.0-rc1: https://github.com/dotnet/runtime/actions/runs/2906074446 |
This is speculative fix for #73621 and #69125.
I was unable to reproduce it locally so this is based on code inspection, experiments and discussions on #73621.
The assumption is that this is regression caused by #64369
The theory is like this:
OpenSSL has its own referencing mechanism. The particular
SSLstructure it can still hold reference toSSL_CTXit was created with. That for example allows to use TLS session cache attached toSSL_CTX.Now, from .NET prospective the
SafeSslContextHandlerepresentingSSL_CTXcan be released as soon as we createSafeSslHandle- we don't use it for anything else but initial setup. CallingReleaseHandlewould free theGCHandleand if any of the callbacks fire after that, they can step on memory that holds garbage.This change grabs reference on
SafeSslContextHandle(if eligible for TLS resume) to preserve it while the session is in use to mimicOpenSSLlife cycle. With that, the native callbacks should point to valid memory.The crashes are happening daily in CI so we should know in next few days if this fixes the crashes.