Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

[release/3.1] Port 6.0 fix to AssemblyDependencyResolver to not throw for same file - #28161

Merged
agocke merged 9 commits into
dotnet:release/3.1from
LakshanF:fix-37162
May 5, 2021
Merged

[release/3.1] Port 6.0 fix to AssemblyDependencyResolver to not throw for same file#28161
agocke merged 9 commits into
dotnet:release/3.1from
LakshanF:fix-37162

Conversation

@LakshanF

@LakshanF LakshanF commented Apr 19, 2021

Copy link
Copy Markdown

Runtime follow up fixes for .NET 3.1 - dotnet/runtime#42055

Description

There is a problem with resolving multiple files with the same simple name (e.g. Module, module) in case insensitive OS like Windows for AssemblyDependencyResolver. Our internal storage for such cases throws that can cause problems for users who do not expect the error.

Customer Impact

Reported by customer who was migrating to .Net Core from the Desktop runtime.

After migrating the mixed-mode C++/CLI application from targeting .NET Framework over to .NET Core 3.1, several obstacles have been encountered. One of them is an exception related to adding a duplicate key to a Dictionary in the AssemblyDependencyResolver. Alternatively, they might get an exception about the assembly having already been found with a different extension. Both of these problem point back to .NET Core having a mixture of case sensitivity and insensitivity.

Regression

No, it has always existed.

Testing

Added test scenarios.

A customer who ran into this in 5.0 tried the 6.0 build and reported success.

Risk

Low.

Although getting casing correct with different OSs are notoriously hard, the resolution was to make AssemblyDependencyResolver consistent with other parts of the runtime by choosing the first simple file name and not throwing afterwards for same simple filename with different casing

The 6.0 issue is dotnet/runtime#37162

@vitek-karas vitek-karas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try to port at least one test to validate this.

@jeffschwMSFT

Copy link
Copy Markdown
Member

Once you are ready for review, please add the servicing template (here is an example dotnet/runtime#51421)

@LakshanF
LakshanF requested a review from agocke April 19, 2021 19:32
@LakshanF LakshanF changed the title Port 6.0 fix to AssemblyDependencyResolver to not throw for same file [release/3.1] Port 6.0 fix to AssemblyDependencyResolver to not throw for same file Apr 21, 2021
Comment thread src/corefx/System.Globalization.Native/pal_calendarData.c Outdated
@agocke

agocke commented Apr 23, 2021

Copy link
Copy Markdown
Member

@vitek-karas @elinor-fung anything else?

@agocke

agocke commented Apr 23, 2021

Copy link
Copy Markdown
Member

Mac fix moved to #28163

@elinor-fung

Copy link
Copy Markdown
Member

Can we get a run of the added AssemblyDependencyResolver tests on all platforms? They have CLRTestPriority=1, so I don't believe they were run with the PR.

@elinor-fung

Copy link
Copy Markdown
Member

/azp help

@azure-pipelines

Copy link
Copy Markdown
Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@elinor-fung

Copy link
Copy Markdown
Member

/azp list

@azure-pipelines

Copy link
Copy Markdown

@agocke

agocke commented Apr 24, 2021

Copy link
Copy Markdown
Member

/azp run coreclr-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

@agocke

agocke commented Apr 26, 2021

Copy link
Copy Markdown
Member

@elinor-fung Any luck on finding the right thing to run? I agree it looks like only P0 tests are being run, but I can't find a switch to run the rest,

@elinor-fung

Copy link
Copy Markdown
Member

Looks like the triggers for it don't include release/3.*. I manually queued a run: https://dev.azure.com/dnceng/public/_build/results?buildId=1108340
I think it should end up reflected in the checks here.

@elinor-fung

Copy link
Copy Markdown
Member

Test is failing on Linux: https://helix.dot.net/api/2019-06-17/jobs/552434ac-d9d3-439b-a1d2-2ffe86271a87/workitems/PayloadGroup0/console

TestAssemblyWithCaseReversed Start
TestAssemblyWithCaseReversed FAILED:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> Xunit.Sdk.EqualException: Assert.Equal() Failure
Expected: /home/helixbot/work/A9800949/w/9E9A0883/e/Loader/AssemblyDependencyResolver/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests/TestComponent_15a025f6/TestAssemblyWithCaseReversed.dll
Actual:   (null)
   at Xunit.Assert.Equal[T](T expected, T actual, IEqualityComparer`1 comparer) in C:\projects\xunit\src\xunit.assert\Asserts\EqualityAsserts.cs:line 40
   at AssemblyDependencyResolverTests.AssemblyDependencyResolverTests.TestAssemblyWithCaseReversed() in /__w/1/s/tests/src/Loader/AssemblyDependencyResolver/AssemblyDependencyResolverTests/AssemblyDependencyResolverTests.cs:line 195
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at AssemblyDependencyResolverTests.TestBase.<>c__DisplayClass18_1.<RunTestsForInstance>b__1() in /__w/1/s/tests/src/Loader/AssemblyDependencyResolver/AssemblyDependencyResolverTests/TestBase.cs:line 87
   at AssemblyDependencyResolverTests.TestBase.RunSingleTest(Action test, String testName) in /__w/1/s/tests/src/Loader/AssemblyDependencyResolver/AssemblyDependencyResolverTests/TestBase.cs:line 70

I expect it is because AssemblyDependencyResolver.ResolveAssemblyToPath does a File.Exists check on the path, respecting case-sensitivity/insensitivity of the system, so when the first path doesn't match the actual file casing, the assert doesn't hold in case-sensitive scenarios.

@LakshanF

Copy link
Copy Markdown
Author

@LakshanF

Copy link
Copy Markdown
Author

The test seems to be passing now

@agocke

agocke commented Apr 29, 2021

Copy link
Copy Markdown
Member

@jeffschwMSFT For servicing check

@wtgodbe for guidance on merging. Anything else we should do here?

@jeffschwMSFT jeffschwMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I will take for consideration for 3.1.x.

@jeffschwMSFT

Copy link
Copy Markdown
Member

@agocke @LakshanF is there a similar change needed for 5.0.x?

@jeffschwMSFT jeffschwMSFT added area-AssemblyLoader Servicing-consider Issue for next servicing release review labels Apr 29, 2021
@jeffschwMSFT jeffschwMSFT added this to the 3.1.x milestone Apr 29, 2021
@wtgodbe

wtgodbe commented Apr 29, 2021

Copy link
Copy Markdown
Member

If tactics approves this we can merge this once branches are open for June, which will be 5/4 - 5/10 (the Tuesday before Patch Tuesday thru the night before Patch Tuesday). Are the CI failures expected?

@LakshanF

Copy link
Copy Markdown
Author

@wtgodbe, the OSX failures that are due to #28163. The test failures in other platforms are not related to this change

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-AssemblyLoader Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants