Skip to content

Native image double mapping #112901

Open
Open
@t-mustafin

Description

@t-mustafin

Native images mapped twice as LAYOUT_FLAT and LAYOUT_LOADED on Linux for main:

7f158e020000-7f158e021000 r--p 00000000 103:01 28346375                  /home/runtime/main_x64_releaseO0/hello/readline.ni.dll
7f158e030000-7f158e031000 r-xp 00000000 103:01 28346375                  /home/runtime/main_x64_releaseO0/hello/readline.ni.dll
7f158e051000-7f158e052000 rw-p 00001000 103:01 28346375                  /home/runtime/main_x64_releaseO0/hello/readline.ni.dll
7f158e071000-7f158e072000 r--p 00001000 103:01 28346375                  /home/runtime/main_x64_releaseO0/hello/readline.ni.dll
7f1608040000-7f1608042000 r--s 00000000 103:01 28346375                  /home/runtime/main_x64_releaseO0/hello/readline.ni.dll
Backtrace for LAYOUT_FLAT
#0  PEImage::GetOrCreateLayoutInternal (this=this@entry=0x556ee6e12c20, imageLayoutMask=imageLayoutMask@entry=15)
    at /home/runtime/src/coreclr/vm/peimage.cpp:693
#1  0x00007f160c07c612 in PEImage::GetOrCreateLayout (this=0x556ee6e12c20, imageLayoutMask=imageLayoutMask@entry=15)
    at /home/runtime/src/coreclr/vm/peimage.cpp:659
#2  0x00007f160c07c52e in PEImage::CheckILFormat (this=0x556ee6e12c20) at /home/runtime/src/coreclr/vm/peimage.cpp:66
#3  0x00007f160c0e01f3 in AssemblySpec::LoadAssembly (pFilePath=<optimized out>) at /home/runtime/src/coreclr/vm/assemblyspec.cpp:439
#4  0x00007f160bfff7f0 in CorHost2::ExecuteAssembly (this=<optimized out>, dwAppDomainId=<optimized out>, 
    pwzAssemblyPath=0x556ee6e08ab0 u"/home/runtime/main_x64_releaseO0/hello/readline.ni.dll", argc=0, argv=0x0, pReturnValue=0x7ffe38def880)
    at /home/runtime/src/coreclr/vm/corhost.cpp:322
#5  0x00007f160bfc51f8 in coreclr_execute_assembly (hostHandle=0x556ee6e12c20, domainId=1, argc=0, argv=<optimized out>, 
    managedAssemblyPath=<optimized out>, exitCode=0x7ffe38def880) at /home/runtime/src/coreclr/dlls/mscoree/exports.cpp:494
#6  0x0000556ee6a40036 in run (config=...) at /home/runtime/src/coreclr/hosts/corerun/corerun.cpp:717
#7  0x0000556ee6a3bd0f in main (argc=<optimized out>, argv=<optimized out>) at /home/runtime/src/coreclr/hosts/corerun/corerun.cpp:967
Backtrace for LAYOUT_LOADED
#0  PEImage::GetOrCreateLayoutInternal (this=this@entry=0x556ee6e12c20, imageLayoutMask=imageLayoutMask@entry=4)
    at /home/runtime/src/coreclr/vm/peimage.cpp:693
#1  0x00007f160c07c612 in PEImage::GetOrCreateLayout (this=0x556ee6e12c20, imageLayoutMask=4) at /home/runtime/src/coreclr/vm/peimage.cpp:659
#2  0x00007f160c07a3d5 in PEAssembly::EnsureLoaded (this=0x556ee6e0dde0) at /home/runtime/src/coreclr/vm/peassembly.cpp:71
#3  0x00007f160bfd32de in Assembly::Init (this=0x556ee6e050d0, pamTracker=pamTracker@entry=0x7ffe38dee5f0)
    at /home/runtime/src/coreclr/vm/assembly.cpp:181
#4  0x00007f160bfd3d80 in Assembly::Create (pPEAssembly=<optimized out>, pamTracker=0x7ffe38dee5f0, pLoaderAllocator=<optimized out>)
    at /home/runtime/src/coreclr/vm/assembly.cpp:352
#5  0x00007f160c007138 in DomainAssembly::DomainAssembly (this=0x556ee6e0dc60, pPEAssembly=0x556ee6e0dde0, 
    pLoaderAllocator=0x7f160c6280c0 <g_pSystemDomainMemory+16>, memTracker=0x7ffe38dee5f0) at /home/runtime/src/coreclr/vm/domainassembly.cpp:35
#6  0x00007f160bfcb391 in AppDomain::LoadAssemblyInternal (this=this@entry=0x556ee6ddc4d0, pIdentity=pIdentity@entry=0x7ffe38deeb88, 
    pPEAssembly=pPEAssembly@entry=0x556ee6e0dde0, targetLevel=targetLevel@entry=FILE_LOADED) at /home/runtime/src/coreclr/vm/appdomain.cpp:2467
#7  0x00007f160bfc842e in AppDomain::LoadAssembly (this=0x556ee6ddc4d0, pSpec=0x7ffe38deeb88, pPEAssembly=0x556ee6e0dde0, 
    targetLevel=FILE_LOADED) at /home/runtime/src/coreclr/vm/appdomain.cpp:2378
#8  0x00007f160c0d8c53 in AssemblyNative::LoadFromPEImage (pBinder=0x556ee6dde9d0, pImage=0x556ee6e12c20, excludeAppPaths=true)
    at /home/runtime/src/coreclr/vm/assemblynative.cpp:173
#9  0x00007f160c0e021a in AssemblySpec::LoadAssembly (pFilePath=<optimized out>) at /home/runtime/src/coreclr/vm/assemblyspec.cpp:442
#10 0x00007f160bfff7f0 in CorHost2::ExecuteAssembly (this=<optimized out>, dwAppDomainId=<optimized out>, 
    pwzAssemblyPath=0x556ee6e08ab0 u"/home/runtime/main_x64_releaseO0/hello/readline.ni.dll", argc=0, argv=0x0, pReturnValue=0x7ffe38def880)
    at /home/runtime/src/coreclr/vm/corhost.cpp:322
#11 0x00007f160bfc51f8 in coreclr_execute_assembly (hostHandle=0x556ee6e12c20, domainId=1, argc=0, argv=<optimized out>, 
    managedAssemblyPath=<optimized out>, exitCode=0x7ffe38def880) at /home/runtime/src/coreclr/dlls/mscoree/exports.cpp:494
#12 0x0000556ee6a40036 in run (config=...) at /home/runtime/src/coreclr/hosts/corerun/corerun.cpp:717
#13 0x0000556ee6a3bd0f in main (argc=<optimized out>, argv=<optimized out>) at /home/runtime/src/coreclr/hosts/corerun/corerun.cpp:967

For release/6.0 exists only one LAYOUT_MAPPED:

7fff7dff0000-7fff7dff1000 r--p 00000000 103:01 28345737                  /home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll
7fff7e000000-7fff7e001000 r-xp 00000000 103:01 28345737                  /home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll
7fff7e011000-7fff7e012000 rw-p 00001000 103:01 28345737                  /home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll
7fff7e021000-7fff7e022000 r--p 00001000 103:01 28345737                  /home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll
Backtrace for release/6.0
#0  PEImage::GetLayoutInternal (this=0x555555685fa0, imageLayoutMask=15, flags=1)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/peimage.cpp:969
#1  0x00007ffff7183ed6 in PEImage::GetLayout (this=0x555555685fa0, imageLayoutMask=15, flags=1)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/peimage.cpp:939
#2  0x00007ffff726746f in BinderAcquireImport (pPEImage=0x555555685fa0, ppIAssemblyMetaDataImport=0x7fffffffb9a0, pdwPAFlags=0x7fffffffb9c0, 
    bNativeImage=0) at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/coreassemblyspec.cpp:257
#3  0x00007ffff757d674 in BINDER_SPACE::AssemblyBinder::GetAssembly (assemblyPath=..., fIsInGAC=0, fExplicitBindToNativeImage=0, 
    ppAssembly=0x7fffffffbb28, szMDAssemblyPath=0x0, bundleFileLocation=...)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/binder/assemblybinder.cpp:1253
#4  0x00007ffff757c703 in BINDER_SPACE::AssemblyBinder::BindWhereRef (pApplicationContext=0x55555561fcd8, assemblyPath=..., 
    fNgenExplicitBind=0, fExplicitBindToNativeImage=0, excludeAppPaths=false, pBindResult=0x7fffffffbc68)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/binder/assemblybinder.cpp:597
#5  0x00007ffff757bd00 in BINDER_SPACE::AssemblyBinder::BindAssembly (pApplicationContext=0x55555561fcd8, pAssemblyName=0x0, 
    szCodeBase=0x555555650210 u"/home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll", pParentAssembly=0x0, 
    fNgenExplicitBind=0, fExplicitBindToNativeImage=0, excludeAppPaths=false, ppAssembly=0x7fffffffc0d0)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/binder/assemblybinder.cpp:300
#6  0x00007ffff75894c4 in CLRPrivBinderCoreCLR::Bind (this=0x55555561fc90, 
    wszCodeBase=0x555555650210 u"/home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll", pParentAssembly=0x0, 
    fNgenExplicitBind=0, fExplicitBindToNativeImage=0, ppAssembly=0x7fffffffc2b8)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/binder/clrprivbindercoreclr.cpp:238
#7  0x00007ffff72664d0 in AssemblySpec::Bind (this=0x7fffffffd5a0, pAppDomain=0x5555555f6e30, fThrowOnFileNotFound=0, pResult=0x7fffffffceb8, 
    fNgenExplicitBind=0, fExplicitBindToNativeImage=0) at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/coreassemblyspec.cpp:137
#8  0x00007ffff7038daf in AppDomain::BindAssemblySpec (this=0x5555555f6e30, pSpec=0x7fffffffd5a0, fThrowOnFileNotFound=1)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/appdomain.cpp:3983
#9  0x00007ffff7225d9c in AssemblySpec::LoadDomainAssembly (this=0x7fffffffd5a0, targetLevel=FILE_LOADED, fThrowOnFileNotFound=1)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/assemblyspec.cpp:812
#10 0x00007ffff7225c21 in AssemblySpec::LoadAssembly (this=0x7fffffffd5a0, targetLevel=FILE_LOADED, fThrowOnFileNotFound=1)
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/assemblyspec.cpp:673
#11 0x00007ffff7226257 in AssemblySpec::LoadAssembly (
    pFilePath=0x555555650210 u"/home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll")
    at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/assemblyspec.cpp:862
#12 0x00007ffff70badff in CorHost2::ExecuteAssembly (this=0x5555555d29a0, dwAppDomainId=1, 
    pwzAssemblyPath=0x555555650210 u"/home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll", argc=0, argv=0x0, 
    pReturnValue=0x7fffffffdacc) at /home/tmustafin/dotnet/another_runtime/src/coreclr/vm/corhost.cpp:359
#13 0x00007ffff702fb9d in coreclr_execute_assembly (hostHandle=0x5555555d29a0, domainId=1, argc=0, argv=0x555555585dd0, 
    managedAssemblyPath=0x555555585930 "/home/tmustafin/dotnet/another_runtime/6.0_x64_releaseO0/hello/readline.ni.dll", 
    exitCode=0x7fffffffdacc) at /home/tmustafin/dotnet/another_runtime/src/coreclr/dlls/mscoree/unixinterface.cpp:475
#14 0x000055555555b6fb in run (config=...) at /home/tmustafin/dotnet/another_runtime/src/coreclr/hosts/corerun/corerun.cpp:372
#15 0x00005555555589ef in main (argc=2, argv=0x7fffffffe218) at /home/tmustafin/dotnet/another_runtime/src/coreclr/hosts/corerun/corerun.cpp:554

Double mapping for each loaded native image increases of memory consumption.
@VSadov @jkotas Why native images mapped twice on Linux?

cc @gbalykov

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions