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

Update CoreClr to beta-25011-03 (master)#16064

Closed
dotnet-bot wants to merge 1 commit into
dotnet:masterfrom
dotnet-bot:master-UpdateDependencies
Closed

Update CoreClr to beta-25011-03 (master)#16064
dotnet-bot wants to merge 1 commit into
dotnet:masterfrom
dotnet-bot:master-UpdateDependencies

Conversation

@dotnet-bot
Copy link
Copy Markdown

@dotnet-bot dotnet-bot commented Feb 11, 2017

No description provided.

@stephentoub
Copy link
Copy Markdown
Member

@gkhanna79, did something change very recently related to load contexts? This test is failing across most of the legs... looks like we're getting back a different type than the test expects:

     System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssembly [FAIL]
        Assert.Equal() Failure
        Expected: RefEmitLoadContext { }
        Actual:   AppPathAssemblyLoadContext { }
        Stack Trace:
           /mnt/resource/j/workspace/dotnet_corefx/master/portablelinux_debug_prtest/src/System.Runtime.Loader/tests/RefEmitLoadContext/RefEmitLoadContextTest.cs(123,0): at System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssemblyInLoadContext(AssemblyLoadContext loadContext, AssemblyBuilderAccess builderType)
           /mnt/resource/j/workspace/dotnet_corefx/master/portablelinux_debug_prtest/src/System.Runtime.Loader/tests/RefEmitLoadContext/RefEmitLoadContextTest.cs(83,0): at System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssembly()

@gkhanna79
Copy link
Copy Markdown
Member

@stephentoub Can you please file an issue and disable the test? I will take a look.

@dotnet-bot dotnet-bot changed the title Update CoreClr to beta-25011-02 (master) Update CoreClr to beta-25011-03 (master) Feb 11, 2017
@dotnet-bot dotnet-bot force-pushed the master-UpdateDependencies branch from 5302189 to ca5865b Compare February 11, 2017 18:28
@gkhanna79
Copy link
Copy Markdown
Member

I have looked into this issue and understand what is happening. We did have a change to binder (dotnet/coreclr#9324) but that was unlikely to cause the problem.

Summary is that this is a test issue.

The test is expected to have the following call sequence (callstack grows from top to bottom):

RefEmitLoadContextTest.LoadRefEmitAssemblyInLoadContext [lives in physical assembly loaded in default context]

RefEmitTestType.LoadStaticAssembly [lives in dynamically emitted assembly that is associated with custom load context]

Assembly.Load

In the failing case, the JIT was inlining/optimizing out the method in the middle. As a result, when Assembly.Load would perform the stack walk to determine its caller, it would think RefEmitLoadContextTest is the assembly triggering the load when it is not.

Since RefEmitLoadContextTest is loaded in default context (as it is part of the test), its load context does not match the custom load context of the assembly loaded by the dynamically generated code. Here is the callstack exhibiting this issue:

05 00000012`f5df9d80 00007ffb`131ddf83 System_Private_CoreLib_ni!System.Reflection.Assembly.Load(System.Reflection.AssemblyName)+0xef [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\Assembly.cs @ 216] 
06 00000012`f5df9e10 00007ffb`12e3322e coreclr!CallDescrWorkerInternal+0x83 [E:\GH\gkhanna79\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
07 00000012`f5df9e50 00007ffb`13237b92 coreclr!CallDescrWorkerWithHandler+0x1de [e:\gh\gkhanna79\coreclr\src\vm\callhelpers.cpp @ 92] 
08 00000012`f5df9ed0 00007ffb`1322618d coreclr!`CallDescrWorkerReflectionWrapper'::`6'::__Body::Run+0x52 [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
09 00000012`f5df9f10 00007ffb`13234dca coreclr!CallDescrWorkerReflectionWrapper+0x4d [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
0a 00000012`f5df9f80 00007ffb`0e1b007d coreclr!RuntimeMethodHandle::InvokeMethod+0xefa [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1651] 
0b 00000012`f5dfa8b0 00007ffb`0e1afec1 System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])+0xed [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 628] 
0c 00000012`f5dfa950 00007ffb`0e1a82ae System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x181 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 608] 
0d 00000012`f5dfaa20 00007ffa`b4394ccb System_Private_CoreLib_ni!System.Reflection.MethodBase.Invoke(System.Object, System.Object[])+0x5e [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodBase.cs @ 182] 
0e 00000012`f5dfaa70 00007ffa`b4390a5f System_Runtime_Loader_RefEmitLoadContext_Tests!System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssemblyInLoadContext(System.Runtime.Loader.AssemblyLoadContext, System.Reflection.Emit.AssemblyBuilderAccess)+0x3cb [E:\GH\gkhanna79\corefx\src\System.Runtime.Loader\tests\RefEmitLoadContext\RefEmitLoadContextTest.cs @ 119] 
0f 00000012`f5dfac10 00007ffb`131ddf83 System_Runtime_Loader_RefEmitLoadContext_Tests!System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssembly()+0x5f [E:\GH\gkhanna79\corefx\src\System.Runtime.Loader\tests\RefEmitLoadContext\RefEmitLoadContextTest.cs @ 83] 
10 00000012`f5dfac70 00007ffb`12e3322e coreclr!CallDescrWorkerInternal+0x83 [E:\GH\gkhanna79\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
11 00000012`f5dfacb0 00007ffb`13237b92 coreclr!CallDescrWorkerWithHandler+0x1de [e:\gh\gkhanna79\coreclr\src\vm\callhelpers.cpp @ 92] 
12 00000012`f5dfad30 00007ffb`1322618d coreclr!`CallDescrWorkerReflectionWrapper'::`6'::__Body::Run+0x52 [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
13 00000012`f5dfad70 00007ffb`13234dca coreclr!CallDescrWorkerReflectionWrapper+0x4d [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
14 00000012`f5dfade0 00007ffb`0e1b0039 coreclr!RuntimeMethodHandle::InvokeMethod+0xefa [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1651] 
15 00000012`f5dfb710 00007ffb`0e1afec1 System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])+0xa9 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 625] 
16 00000012`f5dfb7b0 00007ffb`0e1a82ae System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x181 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 608] 

After making the change to the test to ensure the dynamically emitted method will not be inlined, we get the expected callstack with the frame corresponding to the dynamically emitted assembly:

00 000000f5`83af9b18 00007ffb`0e1b64a2 coreclr!AssemblyNative::Load [e:\gh\gkhanna79\coreclr\src\vm\assemblynative.cpp @ 149] 
01 000000f5`83af9b20 00007ffb`0e1b6317 System_Private_CoreLib_ni!System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, IntPtr)+0x82 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\Assembly.cs @ 1240] 
02 000000f5`83af9b90 00007ffb`0e1b612d System_Private_CoreLib_ni!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, IntPtr)+0x1c7 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\Assembly.cs @ 1188] 
03 000000f5`83af9c70 00007ffb`0e1c2d4f System_Private_CoreLib_ni!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, Boolean, Boolean, IntPtr)+0x6d [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\Assembly.cs @ 1156] 
04 000000f5`83af9cd0 00007ffa`b437649d System_Private_CoreLib_ni!System.Reflection.Assembly.Load(System.Reflection.AssemblyName)+0xef [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\Assembly.cs @ 216] 
05 000000f5`83af9d60 00007ffb`131ddf83 **RefEmitTestType.LoadStaticAssembly(System.String)+0x3d**
06 000000f5`83af9da0 00007ffb`12e3322e coreclr!CallDescrWorkerInternal+0x83 [E:\GH\gkhanna79\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
07 000000f5`83af9de0 00007ffb`13237b92 coreclr!CallDescrWorkerWithHandler+0x1de [e:\gh\gkhanna79\coreclr\src\vm\callhelpers.cpp @ 92] 
08 000000f5`83af9e60 00007ffb`1322618d coreclr!`CallDescrWorkerReflectionWrapper'::`6'::__Body::Run+0x52 [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
09 000000f5`83af9ea0 00007ffb`13234dca coreclr!CallDescrWorkerReflectionWrapper+0x4d [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
0a 000000f5`83af9f10 00007ffb`0e1b007d coreclr!RuntimeMethodHandle::InvokeMethod+0xefa [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1651] 
0b 000000f5`83afa840 00007ffb`0e1afec1 System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])+0xed [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 628] 
0c 000000f5`83afa8e0 00007ffb`0e1a82ae System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x181 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 608] 
0d 000000f5`83afa9b0 00007ffa`b4374ccb System_Private_CoreLib_ni!System.Reflection.MethodBase.Invoke(System.Object, System.Object[])+0x5e [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodBase.cs @ 182] 
0e 000000f5`83afaa00 00007ffa`b4370a5f System_Runtime_Loader_RefEmitLoadContext_Tests!System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssemblyInLoadContext(System.Runtime.Loader.AssemblyLoadContext, System.Reflection.Emit.AssemblyBuilderAccess)+0x3cb [E:\GH\gkhanna79\corefx\src\System.Runtime.Loader\tests\RefEmitLoadContext\RefEmitLoadContextTest.cs @ 119] 
0f 000000f5`83afaba0 00007ffb`131ddf83 System_Runtime_Loader_RefEmitLoadContext_Tests!System.Runtime.Loader.Tests.RefEmitLoadContextTests.LoadRefEmitAssembly()+0x5f [E:\GH\gkhanna79\corefx\src\System.Runtime.Loader\tests\RefEmitLoadContext\RefEmitLoadContextTest.cs @ 83] 
10 000000f5`83afac00 00007ffb`12e3322e coreclr!CallDescrWorkerInternal+0x83 [E:\GH\gkhanna79\coreclr\src\vm\amd64\CallDescrWorkerAMD64.asm @ 101] 
11 000000f5`83afac40 00007ffb`13237b92 coreclr!CallDescrWorkerWithHandler+0x1de [e:\gh\gkhanna79\coreclr\src\vm\callhelpers.cpp @ 92] 
12 000000f5`83afacc0 00007ffb`1322618d coreclr!`CallDescrWorkerReflectionWrapper'::`6'::__Body::Run+0x52 [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
13 000000f5`83afad00 00007ffb`13234dca coreclr!CallDescrWorkerReflectionWrapper+0x4d [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1020] 
14 000000f5`83afad70 00007ffb`0e1b0039 coreclr!RuntimeMethodHandle::InvokeMethod+0xefa [e:\gh\gkhanna79\coreclr\src\vm\reflectioninvocation.cpp @ 1651] 
15 000000f5`83afb6a0 00007ffb`0e1afec1 System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])+0xa9 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 625] 
16 000000f5`83afb740 00007ffb`0e1a82ae System_Private_CoreLib_ni!System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)+0x181 [E:\GH\gkhanna79\coreclr\src\mscorlib\src\System\Reflection\MethodInfo.cs @ 608] 

At this point, Assembly.Load gets the correct caller, determines it is a dynamic assembly and gets it load context and proceeds to use that for binding the intended load, resulting in the expected behavior.

I have pushed a PR for the test fix at #16069.

CC @jkotas

@gkhanna79
Copy link
Copy Markdown
Member

BTW, I did confirm that the test failure happens even without the change to the binder I referenced above and that the test fix works for both with and without the binder changes.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Feb 11, 2017

Let's wait for CoreCLR build with the fix

@jkotas jkotas closed this Feb 11, 2017
@karelz karelz modified the milestone: 2.0.0 Feb 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants