8

在 x64 应用程序中,看起来某些程序集被映射到进程地址空间两次。程序集从相同的位置,在相同的加载上下文中加载。不涉及显式反射 API 或应用程序域。

这不会对具有本机图像 (*.ni.dll) 的本机 DLL 或框架 DLL 进行再现,但对本地构建的程序集以及诸如 System.Threading.Tasks.Dataflow.dll 和 StyleCop.dll 等其他程序集进行再现。

为 x86 编译解决方案时,它不会重现。

我在 Process Explorer 和 VMMap 中看到重复的条目。当我在windbg中中断模块加载时,我在运行x64和x86时看到了不同的行为。

NGENing 组件没有任何区别。

为了演示,我将构建程序集的解决方案和引用该程序集的可执行文件放在一起。我可以提供该代码,但它非常简单:程序集公开一个枚举,EXE 引用该枚举中的一个值并将其打印出来。

当我构建面向 x64 的程序集和 EXE 并运行 EXE 时,我在 VMMap 和 Process Explorer 中看到重复的条目。两者都表明引用的程序集位于同一路径。VMMap 显示两个条目的 .rsrc、.text 和 Header 部分(以及每个条目中的 3 个保留块)。

当我针对 x86 构建完全相同的解决方案并运行 EXE 时,我在 VMMap 和 Process Explorer 中看到程序集的 1 个条目。

我使用“sxe ld TestAssembly”在windbg 下运行了32 位和64 位版本,以观察有问题的程序集的负载。

在下面的堆栈中,您会看到 64 位版本中有 3 个中断,而 32 位版本中只有 2 个。

64 位版本中的前 2 个堆栈看起来与 32 位版本中的 2 个相似,但第 3 个堆栈是 64 位独有的。

有什么想法吗?我知道 64bit 是 2x 32bit,但我没想到程序集会被加载两次!:)

我在这里上传了一个重现问题的解决方案:

https://skydrive.live.com/redir?resid=3C60C20A37311DB4!969&authkey=!AJWx4Cm3XDWeu2M

该 zip 文件中包含重现步骤,但如果有不清楚的地方,请告诉我!

在 64 位中,以下是在 windbg (sxe ld TestAssembly) 下加载程序集时的堆栈:

Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
 Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: C:\src\DualAssemblyLoadTest\bin\x64\Debug\DualAssemblyLoadTest.exe
 ...
 0:000> sxe ld TestAssembly
 0:000> g
 (15ac.a9c): Unknown exception - code 04242420 (first chance)
 ModLoad: 000007fe`f3cf0000 000007fe`f3cf6000   TestAssembly.dll
 ntdll!ZwMapViewOfSection+0xa:
 00000000`77b0159a c3              ret
 0:000> k
 Child-SP          RetAddr           Call Site
 00000000`00498e38 000007fe`fdfd3c90 ntdll!ZwMapViewOfSection+0xa
 00000000`00498e40 00000000`773f316d KERNELBASE!MapViewOfFileEx+0x90
 00000000`00498ec0 000007fe`f1558f22 KERNEL32!MapViewOfFileExStub+0x1d
 00000000`00498f00 000007fe`f155ac0a clr!CLRMapViewOfFileEx+0x42
 00000000`00498f80 000007fe`f155aa36 clr!MappedImageLayout::MappedImageLayout+0x166
 00000000`00499270 000007fe`f152ada9 clr!PEImageLayout::Map+0x47
 00000000`004992e0 000007fe`f152ad42 clr! ?? ::FNODOBFM::`string'+0x5b6d5
 00000000`00499330 000007fe`f1518273 clr! ?? ::FNODOBFM::`string'+0x5b5ba
 00000000`004993b0 000007fe`f1517c67 clr!RuntimeOpenImageInternal+0xc3
 00000000`00499480 000007fe`f1517b83 clr!GetAssemblyMDInternalImportEx+0xd9
 00000000`00499500 000007fe`f1565007 clr!CreateMetaDataImport+0x1b
 00000000`00499540 000007fe`f1564f69 clr!CAssemblyManifestImport::InitAndLoadMetaData+0x63
 00000000`00499590 000007fe`f1567b7f clr!CreateAssemblyManifestImport+0x99
 00000000`004995e0 000007fe`f156862d clr!CAsmDownloadMgr::CreateAssembly+0x110
 00000000`00499d90 000007fe`f1568243 clr!CAsmDownloadMgr::DoSetupRFS+0xc6
 00000000`0049a1a0 000007fe`f1567e1c clr!CAsmDownloadMgr::DoSetup+0x1d0
 00000000`0049a4b0 000007fe`f156672b clr!CAssemblyDownload::DoSetup+0xb8
 00000000`0049a550 000007fe`f1566615 clr!CAssemblyDownload::DownloadComplete+0xbb
 00000000`0049a5a0 000007fe`f1565094 clr!CAssemblyDownload::KickOffDownload+0x16d
 00000000`0049a880 000007fe`f151c5df clr!CAssemblyName::BindToObject+0x543
 00000000`0049a9d0 000007fe`f151c374 clr!FusionBind::RemoteLoad+0x1cf
 00000000`0049ab00 000007fe`f151c0ba clr!FusionBind::LoadAssembly+0x1d4
 00000000`0049ac20 000007fe`f151b3bd clr!AssemblySpec::FindAssemblyFile+0x116
 00000000`0049b3b0 000007fe`f1527ba4 clr!AppDomain::BindAssemblySpec+0x35e
 00000000`0049c5f0 000007fe`f15279fa clr!PEFile::LoadAssembly+0xe8
 00000000`0049c720 000007fe`f155b8fe clr!Module::LoadAssembly+0x361
 00000000`0049c9c0 000007fe`f14fd17b clr!Assembly::FindModuleByTypeRef+0x18f
 00000000`0049cd10 000007fe`f14f02d9 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x452
 00000000`0049ce50 000007fe`eeb0950e clr!CEEInfo::resolveToken+0xc58
 00000000`0049d520 000007fe`eeabaac7 clrjit!ReaderBase::readBytesForFlowGraphNode_Helper+0x1389
 00000000`0049d940 000007fe`eeabf316 clrjit!ReaderBase::readBytesForFlowGraphNode+0x1a7
 00000000`0049da10 000007fe`eeac0c65 clrjit!ReaderBase::MSILToIR+0x186
 00000000`0049da70 000007fe`eeac0c06 clrjit!ReadProc+0x26
 00000000`0049dc40 000007fe`eeaa5d27 clrjit!THX_dop2_ReadProc+0x36
 00000000`0049dc70 000007fe`eeab732b clrjit!THX_dop2+0x77
 00000000`0049dcf0 000007fe`f15d07ee clrjit!PreJit::compileMethod+0x67
 00000000`0049dd70 000007fe`f15d073f clr!invokeCompileMethodHelper+0x6a
 00000000`0049ddc0 000007fe`f15d062e clr!invokeCompileMethod+0x8f
 00000000`0049de30 000007fe`f15d050c clr!CallCompileMethodWithSEHWrapper+0x46
 00000000`0049dec0 000007fe`f154e88a clr!UnsafeJitFunction+0x23c
 00000000`0049e440 000007fe`f1500971 clr!MethodDesc::MakeJitWorker+0x4ea
 00000000`0049e690 000007fe`f14ffecb clr!MethodDesc::DoPrestub+0xb1c
 00000000`0049eb70 000007fe`f14b24da clr!PreStubWorker+0x3eb
 00000000`0049ee70 000007fe`f14ff713 clr!ThePreStub+0x5a
 00000000`0049ef40 000007fe`f14ff242 clr!CallDescrWorkerInternal+0x83
 00000000`0049ef80 000007fe`f14ff30b clr!CallDescrWorkerWithHandler+0x4a
 00000000`0049efc0 000007fe`f169721c clr!MethodDescCallSite::CallTargetWorker+0x2e6
 00000000`0049f170 000007fe`f1697976 clr!RunMain+0x1e7
 00000000`0049f340 000007fe`f1697870 clr!Assembly::ExecuteMainMethod+0xb6
 00000000`0049f630 000007fe`f16973e6 clr!SystemDomain::ExecuteMainMethod+0x45e
 00000000`0049fbf0 000007fe`f169733e clr!ExecuteEXE+0x3f
 00000000`0049fc60 000007fe`f1693ed4 clr!CorExeMainInternal+0xae
 00000000`0049fcf0 000007fe`f99c74e5 clr!CorExeMain+0x14
 00000000`0049fd30 000007fe`f9c65b21 mscoreei!CorExeMain+0xe0
 00000000`0049fd80 00000000`773e652d MSCOREE!CorExeMain_Exported+0x57
 00000000`0049fdb0 00000000`77adc521 KERNEL32!BaseThreadInitThunk+0xd
 00000000`0049fde0 00000000`00000000 ntdll!RtlUserThreadStart+0x1d
 0:000> g
 ModLoad: 00000000`006b0000 00000000`006b6000   TestAssembly.dll
 ntdll!ZwMapViewOfSection+0xa:
 00000000`77b0159a c3              ret
 0:000> k
 Child-SP          RetAddr           Call Site
 00000000`00498e38 000007fe`fdfd3c90 ntdll!ZwMapViewOfSection+0xa
 00000000`00498e40 00000000`773f316d KERNELBASE!MapViewOfFileEx+0x90
 00000000`00498ec0 000007fe`f1558f22 KERNEL32!MapViewOfFileExStub+0x1d
 00000000`00498f00 000007fe`f155ac6b clr!CLRMapViewOfFileEx+0x42
 00000000`00498f80 000007fe`f155aa36 clr!MappedImageLayout::MappedImageLayout+0x1c7
 00000000`00499270 000007fe`f152ada9 clr!PEImageLayout::Map+0x47
 00000000`004992e0 000007fe`f152ad42 clr! ?? ::FNODOBFM::`string'+0x5b6d5
 00000000`00499330 000007fe`f1518273 clr! ?? ::FNODOBFM::`string'+0x5b5ba
 00000000`004993b0 000007fe`f1517c67 clr!RuntimeOpenImageInternal+0xc3
 00000000`00499480 000007fe`f1517b83 clr!GetAssemblyMDInternalImportEx+0xd9
 00000000`00499500 000007fe`f1565007 clr!CreateMetaDataImport+0x1b
 00000000`00499540 000007fe`f1564f69 clr!CAssemblyManifestImport::InitAndLoadMetaData+0x63
 00000000`00499590 000007fe`f1567b7f clr!CreateAssemblyManifestImport+0x99
 00000000`004995e0 000007fe`f156862d clr!CAsmDownloadMgr::CreateAssembly+0x110
 00000000`00499d90 000007fe`f1568243 clr!CAsmDownloadMgr::DoSetupRFS+0xc6
 00000000`0049a1a0 000007fe`f1567e1c clr!CAsmDownloadMgr::DoSetup+0x1d0
 00000000`0049a4b0 000007fe`f156672b clr!CAssemblyDownload::DoSetup+0xb8
 00000000`0049a550 000007fe`f1566615 clr!CAssemblyDownload::DownloadComplete+0xbb
 00000000`0049a5a0 000007fe`f1565094 clr!CAssemblyDownload::KickOffDownload+0x16d
 00000000`0049a880 000007fe`f151c5df clr!CAssemblyName::BindToObject+0x543
 00000000`0049a9d0 000007fe`f151c374 clr!FusionBind::RemoteLoad+0x1cf
 00000000`0049ab00 000007fe`f151c0ba clr!FusionBind::LoadAssembly+0x1d4
 00000000`0049ac20 000007fe`f151b3bd clr!AssemblySpec::FindAssemblyFile+0x116
 00000000`0049b3b0 000007fe`f1527ba4 clr!AppDomain::BindAssemblySpec+0x35e
 00000000`0049c5f0 000007fe`f15279fa clr!PEFile::LoadAssembly+0xe8
 00000000`0049c720 000007fe`f155b8fe clr!Module::LoadAssembly+0x361
 00000000`0049c9c0 000007fe`f14fd17b clr!Assembly::FindModuleByTypeRef+0x18f
 00000000`0049cd10 000007fe`f14f02d9 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x452
 00000000`0049ce50 000007fe`eeb0950e clr!CEEInfo::resolveToken+0xc58
 00000000`0049d520 000007fe`eeabaac7 clrjit!ReaderBase::readBytesForFlowGraphNode_Helper+0x1389
 00000000`0049d940 000007fe`eeabf316 clrjit!ReaderBase::readBytesForFlowGraphNode+0x1a7
 00000000`0049da10 000007fe`eeac0c65 clrjit!ReaderBase::MSILToIR+0x186
 00000000`0049da70 000007fe`eeac0c06 clrjit!ReadProc+0x26
 00000000`0049dc40 000007fe`eeaa5d27 clrjit!THX_dop2_ReadProc+0x36
 00000000`0049dc70 000007fe`eeab732b clrjit!THX_dop2+0x77
 00000000`0049dcf0 000007fe`f15d07ee clrjit!PreJit::compileMethod+0x67
 00000000`0049dd70 000007fe`f15d073f clr!invokeCompileMethodHelper+0x6a
 00000000`0049ddc0 000007fe`f15d062e clr!invokeCompileMethod+0x8f
 00000000`0049de30 000007fe`f15d050c clr!CallCompileMethodWithSEHWrapper+0x46
 00000000`0049dec0 000007fe`f154e88a clr!UnsafeJitFunction+0x23c
 00000000`0049e440 000007fe`f1500971 clr!MethodDesc::MakeJitWorker+0x4ea
 00000000`0049e690 000007fe`f14ffecb clr!MethodDesc::DoPrestub+0xb1c
 00000000`0049eb70 000007fe`f14b24da clr!PreStubWorker+0x3eb
 00000000`0049ee70 000007fe`f14ff713 clr!ThePreStub+0x5a
 00000000`0049ef40 000007fe`f14ff242 clr!CallDescrWorkerInternal+0x83
 00000000`0049ef80 000007fe`f14ff30b clr!CallDescrWorkerWithHandler+0x4a
 00000000`0049efc0 000007fe`f169721c clr!MethodDescCallSite::CallTargetWorker+0x2e6
 00000000`0049f170 000007fe`f1697976 clr!RunMain+0x1e7
 00000000`0049f340 000007fe`f1697870 clr!Assembly::ExecuteMainMethod+0xb6
 00000000`0049f630 000007fe`f16973e6 clr!SystemDomain::ExecuteMainMethod+0x45e
 00000000`0049fbf0 000007fe`f169733e clr!ExecuteEXE+0x3f
 00000000`0049fc60 000007fe`f1693ed4 clr!CorExeMainInternal+0xae
 00000000`0049fcf0 000007fe`f99c74e5 clr!CorExeMain+0x14
 00000000`0049fd30 000007fe`f9c65b21 mscoreei!CorExeMain+0xe0
 00000000`0049fd80 00000000`773e652d MSCOREE!CorExeMain_Exported+0x57
 00000000`0049fdb0 00000000`77adc521 KERNEL32!BaseThreadInitThunk+0xd
 00000000`0049fde0 00000000`00000000 ntdll!RtlUserThreadStart+0x1d
 0:000> g
 ModLoad: 000007fe`f3cf0000 000007fe`f3cf6000   C:\src\DualAssemblyLoadTest\bin\x64\Debug\TestAssembly.dll
 ntdll!ZwMapViewOfSection+0xa:
 00000000`77b0159a c3              ret
 0:000> k
 Child-SP          RetAddr           Call Site
 00000000`0049b468 00000000`77aeacfc ntdll!ZwMapViewOfSection+0xa
 00000000`0049b470 00000000`77ae1327 ntdll!LdrpMapViewOfSection+0xbc
 00000000`0049b520 00000000`77ad7cc8 ntdll!LdrpFindOrMapDll+0x469
 00000000`0049b6a0 00000000`77ad7b2e ntdll!LdrpLoadDll+0x148
 00000000`0049b8b0 000007fe`fdfcc71f ntdll!LdrLoadDll+0x9a
 00000000`0049b920 000007fe`f150bf54 KERNELBASE!LoadLibraryExW+0x22e
 00000000`0049b990 000007fe`f150bec1 clr!CLRLoadLibraryEx+0xfc
 00000000`0049b9e0 000007fe`f152c30f clr!CLRLoadLibraryEx+0x51
 00000000`0049ba30 000007fe`f152c264 clr!LoadedImageLayout::LoadedImageLayout+0x9e
 00000000`0049bce0 000007fe`f155b133 clr!PEImageLayout::Load+0x3d
 00000000`0049bd20 000007fe`f155af5e clr!PEImage::Load+0x119
 00000000`0049bda0 000007fe`f152372c clr!PEFile::LoadLibrary+0xe2
 00000000`0049bdd0 000007fe`f15236cf clr!DomainFile::LoadLibrary+0x59
 00000000`0049be20 000007fe`f1521078 clr!DomainFile::DoIncrementalLoad+0xf6
 00000000`0049be50 000007fe`f1521463 clr!AppDomain::TryIncrementalLoad+0x145
 00000000`0049c250 000007fe`f1519c38 clr!AppDomain::LoadDomainFile+0x167
 00000000`0049c310 000007fe`f1519a7b clr!AppDomain::LoadDomainAssemblyInternal+0x178
 00000000`0049c400 000007fe`f1527a9c clr!AppDomain::LoadDomainAssembly+0x8c
 00000000`0049c720 000007fe`f155b8fe clr!Module::LoadAssembly+0x403
 00000000`0049c9c0 000007fe`f14fd17b clr!Assembly::FindModuleByTypeRef+0x18f
 00000000`0049cd10 000007fe`f14f02d9 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x452
 00000000`0049ce50 000007fe`eeb0950e clr!CEEInfo::resolveToken+0xc58
 00000000`0049d520 000007fe`eeabaac7 clrjit!ReaderBase::readBytesForFlowGraphNode_Helper+0x1389
 00000000`0049d940 000007fe`eeabf316 clrjit!ReaderBase::readBytesForFlowGraphNode+0x1a7
 00000000`0049da10 000007fe`eeac0c65 clrjit!ReaderBase::MSILToIR+0x186
 00000000`0049da70 000007fe`eeac0c06 clrjit!ReadProc+0x26
 00000000`0049dc40 000007fe`eeaa5d27 clrjit!THX_dop2_ReadProc+0x36
 00000000`0049dc70 000007fe`eeab732b clrjit!THX_dop2+0x77
 00000000`0049dcf0 000007fe`f15d07ee clrjit!PreJit::compileMethod+0x67
 00000000`0049dd70 000007fe`f15d073f clr!invokeCompileMethodHelper+0x6a
 00000000`0049ddc0 000007fe`f15d062e clr!invokeCompileMethod+0x8f
 00000000`0049de30 000007fe`f15d050c clr!CallCompileMethodWithSEHWrapper+0x46
 00000000`0049dec0 000007fe`f154e88a clr!UnsafeJitFunction+0x23c
 00000000`0049e440 000007fe`f1500971 clr!MethodDesc::MakeJitWorker+0x4ea
 00000000`0049e690 000007fe`f14ffecb clr!MethodDesc::DoPrestub+0xb1c
 00000000`0049eb70 000007fe`f14b24da clr!PreStubWorker+0x3eb
 00000000`0049ee70 000007fe`f14ff713 clr!ThePreStub+0x5a
 00000000`0049ef40 000007fe`f14ff242 clr!CallDescrWorkerInternal+0x83
 00000000`0049ef80 000007fe`f14ff30b clr!CallDescrWorkerWithHandler+0x4a
 00000000`0049efc0 000007fe`f169721c clr!MethodDescCallSite::CallTargetWorker+0x2e6
 00000000`0049f170 000007fe`f1697976 clr!RunMain+0x1e7
 00000000`0049f340 000007fe`f1697870 clr!Assembly::ExecuteMainMethod+0xb6
 00000000`0049f630 000007fe`f16973e6 clr!SystemDomain::ExecuteMainMethod+0x45e
 00000000`0049fbf0 000007fe`f169733e clr!ExecuteEXE+0x3f
 00000000`0049fc60 000007fe`f1693ed4 clr!CorExeMainInternal+0xae
 00000000`0049fcf0 000007fe`f99c74e5 clr!CorExeMain+0x14
 00000000`0049fd30 000007fe`f9c65b21 mscoreei!CorExeMain+0xe0
 00000000`0049fd80 00000000`773e652d MSCOREE!CorExeMain_Exported+0x57
 00000000`0049fdb0 00000000`77adc521 KERNEL32!BaseThreadInitThunk+0xd
 00000000`0049fde0 00000000`00000000 ntdll!RtlUserThreadStart+0x1d
 0:000> g

在 32 位中,以下是在 windbg (sxe ld TestAssembly) 下加载程序集时的堆栈:

Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
 Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: bin\x86\Debug\DualAssemblyLoadTest.exe
 ...
 0:000> sxe ld TestAssembly
 0:000> g
 (14cc.15fc): Unknown exception - code 04242420 (first chance)
 ModLoad: 60350000 60358000   TestAssembly.dll
 eax=00000000 ebx=0084a1fc ecx=00000000 edx=00000000 esi=00000000 edi=00000000
 eip=77cafc42 esp=0042adac ebp=0042ade4 iopl=0         nv up ei pl zr na pe nc
 cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
 ntdll!NtMapViewOfSection+0x12:
 77cafc42 83c404          add     esp,4
 0:000> k
 ChildEBP RetAddr  
0042adac 7720e231 ntdll!NtMapViewOfSection+0x12
 0042ade4 6e337b8d KERNELBASE!MapViewOfFileEx+0x81
 0042ae3c 6e337d52 clr!CLRMapViewOfFileEx+0x26
 0042b0ac 6e337e7c clr!MappedImageLayout::MappedImageLayout+0x200
 0042b0f4 6e335ca1 clr!PEImageLayout::Map+0x2c
 0042b12c 6e335d3e clr!PEImage::GetLayoutInternal+0x106
 0042b17c 6e3320e6 clr!PEImage::GetLayout+0xf0
 0042b200 6e33300f clr!RuntimeOpenImageInternal+0x9d
 0042b250 6e35a512 clr!GetAssemblyMDInternalImportEx+0xe6
 0042b288 6e35a5c6 clr!CAssemblyManifestImport::InitAndLoadMetaData+0x59
 0042b2bc 6e35ca67 clr!CreateAssemblyManifestImport+0x50
 0042b97c 6e35d240 clr!CAsmDownloadMgr::CreateAssembly+0x20a
 0042bce4 6e35cf5e clr!CAsmDownloadMgr::DoSetupRFS+0xbf
 0042bf9c 6e35cd0b clr!CAsmDownloadMgr::DoSetup+0x22f
 0042bffc 6e35a6d7 clr!CAssemblyDownload::DoSetup+0xa4
 0042c03c 6e35a894 clr!CAssemblyDownload::DownloadComplete+0x103
 0042c2b0 6e35a920 clr!CAssemblyDownload::KickOffDownload+0x33a
 0042c350 6e32784b clr!CAssemblyName::BindToObject+0x9c1
 0042c3ec 6e327a7d clr!FusionBind::RemoteLoad+0x1fc
 0042c478 6e327c30 clr!FusionBind::LoadAssembly+0x17c
 0042cb54 6e327e6f clr!AssemblySpec::FindAssemblyFile+0x104
 0042d87c 6e325299 clr!AppDomain::BindAssemblySpec+0xffd
 0042d934 6e325103 clr!PEFile::LoadAssembly+0xc0
 0042da08 6e3252e4 clr!Module::LoadAssembly+0x176
 0042dca8 6e2f91ca clr!Assembly::FindModuleByTypeRef+0x1f5
 0042dd14 6e304c27 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x103
 0042ddbc 751d10cf clr!CEEInfo::resolveToken+0x306
 0042ddcc 751fffe8 clrjit!Compiler::impResolveToken+0x3a
 0042e4fc 751d1a60 clrjit!Compiler::impImportBlockCode+0x42f5
 0042e57c 751d1c42 clrjit!Compiler::impImportBlock+0x5d
 0042e594 751d244d clrjit!Compiler::impImport+0x1ea
 0042e5b4 751d401c clrjit!Compiler::compCompile+0x63
 0042e5f0 751d4132 clrjit!Compiler::compCompileHelper+0x2fa
 0042e668 751d4282 clrjit!Compiler::compCompile+0x213
 0042e758 751d4595 clrjit!jitNativeCode+0x1cc
 0042e77c 6e303669 clrjit!CILJit::compileMethod+0x25
 0042e7cc 6e303701 clr!invokeCompileMethodHelper+0x41
 0042e80c 6e303743 clr!invokeCompileMethod+0x31
 0042e870 6e30399c clr!CallCompileMethodWithSEHWrapper+0x2a
 0042ec08 6e303496 clr!UnsafeJitFunction+0x3ca
 0042ecec 6e3040db clr!MethodDesc::MakeJitWorker+0x3a9
 0042ed60 6e2ebcd5 clr!MethodDesc::DoPrestub+0x59d
 0042edc8 6e2d2ae9 clr!PreStubWorker+0xed
 0042edf8 6e2d2652 clr!ThePreStub+0x16
 0042ee04 6e2e264f clr!CallDescrWorkerInternal+0x34
 0042ee58 6e2e2e95 clr!CallDescrWorkerWithHandler+0x6b
 0042eed0 6e3974ec clr!MethodDescCallSite::CallTargetWorker+0x152
 0042effc 6e397610 clr!RunMain+0x1aa
 0042f270 6e421dc4 clr!Assembly::ExecuteMainMethod+0x124
 0042f774 6e421e67 clr!SystemDomain::ExecuteMainMethod+0x614
 0042f7d0 6e421f7a clr!ExecuteEXE+0x4c
 0042f810 6e42416a clr!_CorExeMainInternal+0xdc
 0042f84c 70e2f5a3 clr!_CorExeMain+0x4d
 0042f888 70ea7f16 mscoreei!_CorExeMain+0x10a
 0042f898 70ea4de3 MSCOREE!ShellShim__CorExeMain+0x99
 0042f8a0 7574339a MSCOREE!_CorExeMain_Exported+0x8
 0042f8ac 77cc9ef2 KERNEL32!BaseThreadInitThunk+0xe
 0042f8ec 77cc9ec5 ntdll!__RtlUserThreadStart+0x70
 0042f904 00000000 ntdll!_RtlUserThreadStart+0x1b
 0:000> g
 ModLoad: 001e0000 001e8000   TestAssembly.dll
 eax=00000000 ebx=0084a1fc ecx=00000000 edx=00000000 esi=00000000 edi=00000000
 eip=77cafc42 esp=0042adac ebp=0042ade4 iopl=0         nv up ei pl zr na pe nc
 cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
 ntdll!NtMapViewOfSection+0x12:
 77cafc42 83c404          add     esp,4
 0:000> k
 ChildEBP RetAddr  
0042adac 7720e231 ntdll!NtMapViewOfSection+0x12
 0042ade4 6e337b8d KERNELBASE!MapViewOfFileEx+0x81
 0042ae3c 6e337d7d clr!CLRMapViewOfFileEx+0x26
 0042b0ac 6e337e7c clr!MappedImageLayout::MappedImageLayout+0x227
 0042b0f4 6e335ca1 clr!PEImageLayout::Map+0x2c
 0042b12c 6e335d3e clr!PEImage::GetLayoutInternal+0x106
 0042b17c 6e3320e6 clr!PEImage::GetLayout+0xf0
 0042b200 6e33300f clr!RuntimeOpenImageInternal+0x9d
 0042b250 6e35a512 clr!GetAssemblyMDInternalImportEx+0xe6
 0042b288 6e35a5c6 clr!CAssemblyManifestImport::InitAndLoadMetaData+0x59
 0042b2bc 6e35ca67 clr!CreateAssemblyManifestImport+0x50
 0042b97c 6e35d240 clr!CAsmDownloadMgr::CreateAssembly+0x20a
 0042bce4 6e35cf5e clr!CAsmDownloadMgr::DoSetupRFS+0xbf
 0042bf9c 6e35cd0b clr!CAsmDownloadMgr::DoSetup+0x22f
 0042bffc 6e35a6d7 clr!CAssemblyDownload::DoSetup+0xa4
 0042c03c 6e35a894 clr!CAssemblyDownload::DownloadComplete+0x103
 0042c2b0 6e35a920 clr!CAssemblyDownload::KickOffDownload+0x33a
 0042c350 6e32784b clr!CAssemblyName::BindToObject+0x9c1
 0042c3ec 6e327a7d clr!FusionBind::RemoteLoad+0x1fc
 0042c478 6e327c30 clr!FusionBind::LoadAssembly+0x17c
 0042cb54 6e327e6f clr!AssemblySpec::FindAssemblyFile+0x104
 0042d87c 6e325299 clr!AppDomain::BindAssemblySpec+0xffd
 0042d934 6e325103 clr!PEFile::LoadAssembly+0xc0
 0042da08 6e3252e4 clr!Module::LoadAssembly+0x176
 0042dca8 6e2f91ca clr!Assembly::FindModuleByTypeRef+0x1f5
 0042dd14 6e304c27 clr!ClassLoader::LoadTypeDefOrRefThrowing+0x103
 0042ddbc 751d10cf clr!CEEInfo::resolveToken+0x306
 0042ddcc 751fffe8 clrjit!Compiler::impResolveToken+0x3a
 0042e4fc 751d1a60 clrjit!Compiler::impImportBlockCode+0x42f5
 0042e57c 751d1c42 clrjit!Compiler::impImportBlock+0x5d
 0042e594 751d244d clrjit!Compiler::impImport+0x1ea
 0042e5b4 751d401c clrjit!Compiler::compCompile+0x63
 0042e5f0 751d4132 clrjit!Compiler::compCompileHelper+0x2fa
 0042e668 751d4282 clrjit!Compiler::compCompile+0x213
 0042e758 751d4595 clrjit!jitNativeCode+0x1cc
 0042e77c 6e303669 clrjit!CILJit::compileMethod+0x25
 0042e7cc 6e303701 clr!invokeCompileMethodHelper+0x41
 0042e80c 6e303743 clr!invokeCompileMethod+0x31
 0042e870 6e30399c clr!CallCompileMethodWithSEHWrapper+0x2a
 0042ec08 6e303496 clr!UnsafeJitFunction+0x3ca
 0042ecec 6e3040db clr!MethodDesc::MakeJitWorker+0x3a9
 0042ed60 6e2ebcd5 clr!MethodDesc::DoPrestub+0x59d
 0042edc8 6e2d2ae9 clr!PreStubWorker+0xed
 0042edf8 6e2d2652 clr!ThePreStub+0x16
 0042ee04 6e2e264f clr!CallDescrWorkerInternal+0x34
 0042ee58 6e2e2e95 clr!CallDescrWorkerWithHandler+0x6b
 0042eed0 6e3974ec clr!MethodDescCallSite::CallTargetWorker+0x152
 0042effc 6e397610 clr!RunMain+0x1aa
 0042f270 6e421dc4 clr!Assembly::ExecuteMainMethod+0x124
 0042f774 6e421e67 clr!SystemDomain::ExecuteMainMethod+0x614
 0042f7d0 6e421f7a clr!ExecuteEXE+0x4c
 0042f810 6e42416a clr!_CorExeMainInternal+0xdc
 0042f84c 70e2f5a3 clr!_CorExeMain+0x4d
 0042f888 70ea7f16 mscoreei!_CorExeMain+0x10a
 0042f898 70ea4de3 MSCOREE!ShellShim__CorExeMain+0x99
 0042f8a0 7574339a MSCOREE!_CorExeMain_Exported+0x8
 0042f8ac 77cc9ef2 KERNEL32!BaseThreadInitThunk+0xe
 0042f8ec 77cc9ec5 ntdll!__RtlUserThreadStart+0x70
 0042f904 00000000 ntdll!_RtlUserThreadStart+0x1b
 0:000> g

这是来自 VMMap 的信息,显示了一个程序集在该过程中加载了两次,两次加载了相同的部分。

Address            Type           Size       Committed  Private   Total WS  Private WS  Shareable WS  Shared WS  Locked WS  Blocks  Protection              Details                                                                                                 
 00000000006B0000   Image (ASLR)   24         12                   8                     8             8                     6       Execute/Read            C:\src\DualAssemblyLoadTest\bin\x64\Debug\TestAssembly.dll
   00000000006B1000 Image (ASLR)   4                                                                                                 Reserved               
   00000000006B3000 Image (ASLR)   4                                                                                                 Reserved               
   00000000006B5000 Image (ASLR)   4                                                                                                 Reserved               
   00000000006B4000 Image (ASLR)   4          4                                                                                      Read                    .rsrc
   00000000006B2000 Image (ASLR)   4          4                    4                     4             4                             Execute/Read            .text
   00000000006B0000 Image (ASLR)   4          4                    4                     4             4                             Read                    Header

000007FEF3CF0000   Image (ASLR)   24         12                   8                     8             8                     6       Execute/Read            C:\src\DualAssemblyLoadTest\bin\x64\Debug\TestAssembly.dll
   000007FEF3CF1000 Image (ASLR)   4                                                                                                 Reserved               
   000007FEF3CF3000 Image (ASLR)   4                                                                                                 Reserved               
   000007FEF3CF5000 Image (ASLR)   4                                                                                                 Reserved               
   000007FEF3CF4000 Image (ASLR)   4          4                                                                                      Read                    .rsrc
   000007FEF3CF2000 Image (ASLR)   4          4                    4                     4             4                             Execute/Read            .text
   000007FEF3CF0000 Image (ASLR)   4          4                    4                     4             4                             Read                    Header

更新(2014 年 1 月 20 日):

CLR 团队回复了我的Connect 帖子

“感谢您报告此问题。我们已在 .NET Framework 的下一个主要版本中修复它。”

4

0 回答 0