Repository navigation
Run AppDomain.GetAssemblies Reflection.Emit test out of process - #136902
Open
jakobbotsch wants to merge 2 commits into
Open
jakobbotsch wants to merge 2 commits into
jakobbotsch wants to merge 2 commits into
Conversation
The RunAndCollect case of the TypeArgument_ResolvesAgainstDecoratedModule test asserts that the dynamic assembly is collected within 10 GCs. Tests running in parallel in the same process can transiently keep it alive, for example AssemblyTests.DefineDynamicAssembly_AssemblyBuilderLocationIsEmpty_... calls AppDomain.GetAssemblies() and holds the returned array while it enumerates it. When that snapshot lands between assembly creation and collection the assertion fails. Run the test body under RemoteExecutor so no other tests share the process. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fea5a15e-c5cb-4be1-90bf-822f91431c3c
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @dotnet/area-system-reflection |
jkotas
reviewed
Nov 3, 2026
Revert the out of process change to the TypeArgument_ResolvesAgainstDecoratedModule theory, since other tests in this assembly use the same pattern to verify collectability. Instead run the test that calls AppDomain.GetAssemblies, and therefore holds strong references to every loaded assembly, under RemoteExecutor so it no longer interferes with collectible assemblies from parallel tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: fea5a15e-c5cb-4be1-90bf-822f91431c3c
agocke
approved these changes
Nov 3, 2026
jkotas
reviewed
Nov 3, 2026
| [Fact] | ||
| // Runs out of process: AppDomain.GetAssemblies() holds strong references to every loaded assembly, | ||
| // which can keep collectible assemblies created by tests running in parallel alive. | ||
| [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] |
Member
There was a problem hiding this comment.
Looking around - we use a separate test type with [Collection(nameof(DisableParallelization))] in number of places to deal with this problem. It may be preferable to RemoteExecutor since it won't disable the test on platforms where RemoteExecutor is not supported.
Either way, it looks fine to me.
This was referenced Nov 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypeBuilderSetCustomAttribute.SetCustomAttribute_ConstructorInfo_ByteArray_TypeArgument_ResolvesAgainstDecoratedModule(RunAndCollect)asserts that a collectible dynamic assembly is collected within 10 GCs. It fails rarely in CI, for example on Windows x86 checked in #135048.The cause is another test running in parallel in the same process.
AssemblyTests.DefineDynamicAssembly_AssemblyBuilderLocationIsEmpty_InternalAssemblyBuilderLocationIsEmptycallsAppDomain.CurrentDomain.GetAssemblies(), which returns strong references to every loaded assembly, including live collectible assemblies created by other tests, and keeps the array alive while it enumerates it. If that snapshot lands between assembly creation and collection in the collectibility test, the assembly stays alive and the assertion fails.Fix the flakiness by isolating the test that calls
AppDomain.GetAssemblies.