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

_typesInDynamicallyAccessedMembersHierarchy might get modified from a readonly enumeration #1969

Closed
LakshanF opened this issue Apr 15, 2021 · 0 comments · Fixed by #1972
Closed
Assignees
Milestone

Comments

@LakshanF
Copy link
Contributor

There is a CI test failure that indicates a dictionary getting modified while enumerating via a foreach loop. The failure repro's locally when running all the tests but I haven't been able to narrow it down to running a single failing test.

Given that the code does modify _typesInDynamicallyAccessedMembersHierarchy at ApplyDynamicallyAccessedMembersToTypeHierarchyInner() while enumerating, I think it might be faster to change the code to not do that.

Command to run the full tests (should see some tests failing):

  1. Sync to the PR, Fix EventSource trimmer warning runtime#51237, and build locally

  2. build.cmd -ci -arch x64 -os windows -s libs.tests -c Release /p:TestAssemblies=false /p:TestTrimming=true /p:CrossBuild=false /bl:TrimmingTests.binlog

Should be able to see test, EventSourcePropertyValueTest.cs, failing among others

Steps that I tried to repro a single test failure, EventSourcePropertyValueTest (have not been able to repro)

  1. Open the TrimmingTests.binlog, search for illink failure related to EventSourcePropertyValueTest
  2. Copy the illink failure commandline and run

Failure Callstack

##[error]ILLink(0,0): error IL1005: (NETCORE_ENGINEERING_TELEMETRY=Build) System.Diagnostics.Tracing.EventSource.g__GetCreateManifestAndDescriptorsViaLocalMethod|93_0(String): Error processing method 'System.Diagnostics.Tracing.EventSource.g__GetCreateManifestAndDescriptorsViaLocalMethod|93_0(String)' in assembly 'System.Private.CoreLib.dll'
Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: System.Diagnostics.Tracing.EventSource.g__GetCreateManifestAndDescriptorsViaLocalMethod|93_0(String): Error processing method 'System.Diagnostics.Tracing.EventSource.g__GetCreateManifestAndDescriptorsViaLocalMethod|93_0(String)' in assembly 'System.Private.CoreLib.dll'
---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.Dictionary2.Enumerator.MoveNext() at Mono.Linker.Dataflow.DynamicallyAccessedMembersTypeHierarchy.ApplyDynamicallyAccessedMembersToTypeHierarchy(ReflectionMethodBodyScanner reflectionMethodBodyScanner, ReflectionPatternContext& reflectionPatternContext, TypeDefinition type) at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.HandleCall(MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams, ValueNode& methodReturnValue) at Mono.Linker.Dataflow.MethodBodyScanner.HandleCall(MethodBody callingMethodBody, Instruction operation, Stack1 currentStack)
at Mono.Linker.Dataflow.MethodBodyScanner.Scan(MethodBody methodBody)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ScanAndProcessReturnValue(MethodBody methodBody)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
D:\workspace_work\1\s.dotnet\sdk\6.0.100-preview.2.21155.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(59,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [D:\workspace_work\1\s\artifacts\bin\trimmingTests\projects\Microsoft.Extensions.Http.TrimmingTests\AddTypedClientTests\win-x64\project.csproj]
##[error].dotnet\sdk\6.0.100-preview.2.21155.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(59,5): error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants