Uh oh!
There was an error while loading. Please reload this page.
Add ActiveIssue for all named key tests to mitigate invalid memory access - #129367
Conversation
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
There was a problem hiding this comment.
Pull request overview
This PR updates OpenSslNamedKeysTests by adding ActiveIssue annotations to skip many of the named key functional tests while issue #129339 (segfault/memory corruption in System.Security.Cryptography.Tests) is investigated, aiming to keep CI stable.
Changes:
- Added
[ActiveIssue("https://github.com/dotnet/runtime/issues/129339")]to most test methods inOpenSslNamedKeysTests.manual.csto disable them. - Left some tests in the same class still runnable (e.g., argument/URI validation tests), despite the stated intent to disable the suite.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Security.Cryptography/tests/OpenSslNamedKeysTests.manual.cs | Adds ActiveIssue skips to many named key tests to mitigate suspected CI instability from #129339. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…quire manually running
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
vcsjones
commented
Jun 13, 2026
/ba-g timeout on unrelated platform; test only changes to disable some problematic tests. |
Uh oh!
There was an error while loading. Please reload this page.
Freeing an OSSL_LIB_CTX is a somewhat complicated task. It registers per-thread callbacks to mutate thread-local state. Other OpenSSL APIs, like random number generation, also have thread-local state. In the case of the random number generator, it registered a thread data destructor to clean up random state when the thread is shutting down. This, in turn, sees that the OSSL_LIB_CTX is associated with that thread. If the OSSL_LIB_CTX is freed before the thread has shut down, the thread dtor will access invalid memory. OpenSSL requires you to call `OPENSSL_thread_stop_ex` on _all_ threads before calling `OSSL_LIB_CTX_free` to unhook the context from the thread. This is generally not feasible for .NET. As a solution, we are going to not free the context, and re-use it for each provider. Every provider loaded with `SafeEvpPKeyHandle.OpenKeyFromProvider` will create a context and load that provider into it. The context and provider will remain alive for the duration of the process. The number of providers expected to be used in any application is generally expected to be low - likely two or three. 1. The provider and context are now cached, and kept in a heap-backed buffer. There is no resizing strategy or pre-allocated buffer. Opening a new provider results in re-sizing the array. This strategy is likely fine because there will rarely ever be more than a few providers, as already noted. The resizing is managed by a mutex to synchronize access to the array. We could use something like `pthread_rwlock_t` if we wanted to increase complexity. Given that contention on this mutex would only happen from `OpenKeyFromProvider`, I expect it to be rare. 2. Since the context and provider are now alive permanently, the "extra handle" bookkeeping gets simpler. We no longer need to pass it to destroy, and we no longer need to ref-count it. In fact we don't even need a struct at all anymore, the OSSL_LIB_CTX _is_ the extra handle now. 3. This reverts #129367 since the data dependency is resolved.
Freeing an OSSL_LIB_CTX is a somewhat complicated task. It registers per-thread callbacks to mutate thread-local state. Other OpenSSL APIs, like random number generation, also have thread-local state. In the case of the random number generator, it registered a thread data destructor to clean up random state when the thread is shutting down. This, in turn, sees that the OSSL_LIB_CTX is associated with that thread. If the OSSL_LIB_CTX is freed before the thread has shut down, the thread dtor will access invalid memory. OpenSSL requires you to call `OPENSSL_thread_stop_ex` on _all_ threads before calling `OSSL_LIB_CTX_free` to unhook the context from the thread. This is generally not feasible for .NET. As a solution, we are going to not free the context, and re-use it for each provider. Every provider loaded with `SafeEvpPKeyHandle.OpenKeyFromProvider` will create a context and load that provider into it. The context and provider will remain alive for the duration of the process. The number of providers expected to be used in any application is generally expected to be low - likely two or three. 1. The provider and context are now cached, and kept in a heap-backed buffer. There is no resizing strategy or pre-allocated buffer. Opening a new provider results in re-sizing the array. This strategy is likely fine because there will rarely ever be more than a few providers, as already noted. The resizing is managed by a mutex to synchronize access to the array. We could use something like `pthread_rwlock_t` if we wanted to increase complexity. Given that contention on this mutex would only happen from `OpenKeyFromProvider`, I expect it to be rare. 2. Since the context and provider are now alive permanently, the "extra handle" bookkeeping gets simpler. We no longer need to pass it to destroy, and we no longer need to ref-count it. In fact we don't even need a struct at all anymore, the OSSL_LIB_CTX _is_ the extra handle now. 3. This reverts #129367 since the data dependency is resolved.
This adds an
ActiveIssueto all functional members ofOpenSslNamedKeysTestsbecause they are very likely the source of memory corruption that is showing in #129339.Disable the tests for now so that CI is stable while permanent fixes are investigated.