You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[mono] AppContext.BaseDirectory is empty in some cases #31800
When I run runtest.py (see make run-tests-coreclr-all) with Mono Runtime bits inside the Core_Root it crashes with
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'Internal.Microsoft.Extensions.DependencyModel.CompilationLibrary' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Internal.Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment' threw an exception.
---> System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String path)
at Internal.Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.GetApplicationBasePath()
at Internal.Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment..cctor()
--- End of inner exception stack trace ---
at Internal.Microsoft.Extensions.DependencyModel.Resolution.AppBaseCompilationAssemblyResolver..ctor(IFileSystem fileSystem)
at Internal.Microsoft.Extensions.DependencyModel.Resolution.AppBaseCompilationAssemblyResolver..ctor()
at Internal.Microsoft.Extensions.DependencyModel.CompilationLibrary..cctor()
It looks like GetBaseDirectoryCore returns empty string on first usage (and then a correct string after).
The problem appears to be that the assembly preload hook is triggered early, before prepare_thread_to_exec_main is run. On netcore, the preload hook includes a call to managed to locate the BaseDirectory, and the icall returns null because prepare_thread_to_exec_main is where the entry_assembly is actually set.
Activity
EgorBo commentedon Feb 5, 2020
Workaround in https://github.com/dotnet/runtime/pull/31739/files#diff-de0eb416fb154da3c76ecf6c8f5105fb
CoffeeFlux commentedon Feb 5, 2020
In some cases, the domain's
entry_assemblyappears to be null, including during the first call toGetEntryAssembly().CoffeeFlux commentedon Feb 5, 2020
The problem appears to be that the assembly preload hook is triggered early, before
prepare_thread_to_exec_mainis run. On netcore, the preload hook includes a call to managed to locate the BaseDirectory, and the icall returns null becauseprepare_thread_to_exec_mainis where theentry_assemblyis actually set.[loader] Set domain->entry_assembly earlier in startup (#18720)