Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-File: Run from Bundle #36052

Merged
merged 3 commits into from
May 26, 2020
Merged

Conversation

swaroop-sridhar
Copy link
Contributor

This change implements:

Fixes #32822

@ghost
Copy link

ghost commented May 7, 2020

Tagging subscribers to this area: @swaroop-sridhar
Notify danmosemsft if you want to be subscribed.

@swaroop-sridhar swaroop-sridhar requested review from janvorli and VSadov May 7, 2020 22:32
@swaroop-sridhar
Copy link
Contributor Author

CC: @jkotas

// If found, the assembly is loaded from the bundle.
if (Bundle::AppIsBundle())
{
SString candidates[] = { W(".dll"), W(".ni.dll") };
Copy link
Member

Choose a reason for hiding this comment

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

Do we still use the .ni.dll suffix for anything?

Copy link
Member

Choose a reason for hiding this comment

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

If we do decide to keep it it should use the same order as in BindAssemblyByProbingPaths which is that .ni.dll is preferred over .dll. (or rather BindAssemblyByProbingPaths is first called with useNativeImages=true).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidwrighton mentioned here that .ni.dll is used for managed C++ R2R. Has this changed?

Copy link
Member

Choose a reason for hiding this comment

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

Well, I think its still probably the way we should make it work. I'm not sure if it works in practice today though. I know it doesn't work in crossgen2.

StackSString sCoreLib;
StackSString sCoreLib(sCoreLibDir);
StackSString coreLibName(CoreLibName_IL_W);
sCoreLib.Append(coreLibName);
Copy link
Member

@jkotas jkotas May 8, 2020

Choose a reason for hiding this comment

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

Is this fake path going to be actually used for anything in the bundle case? Would it be better to not build it and pass it in at all when we find the payload in the bundle?

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Aside from the tracing just minor stuff.

sCoreLib.Append(CoreLibName_IL_W);
// System.Private.CoreLib.dll is expected to be found at one of the following locations:
// * Non-single-file app: In systemDirectory, beside coreclr.dll
// * Framework-dependent single-file app: In system directory, beside coreclr.dll
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// * Framework-dependent single-file app: In system directory, beside coreclr.dll
// * Framework-dependent single-file app: In systemDirectory, beside coreclr.dll

// If found, the assembly is loaded from the bundle.
if (Bundle::AppIsBundle())
{
SString candidates[] = { W(".dll"), W(".ni.dll") };
Copy link
Member

Choose a reason for hiding this comment

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

If we do decide to keep it it should use the same order as in BindAssemblyByProbingPaths which is that .ni.dll is preferred over .dll. (or rather BindAssemblyByProbingPaths is first called with useNativeImages=true).

&pTPAAssembly,
NULL, // szMDAssemblyPath
Bundle::ProbeAppBundle(assemblyFileName, /* pathIsBundleRelative */ true));

Copy link
Member

Choose a reason for hiding this comment

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

We should trace the attempt, just like below whenever we probe we also trace the attempt.

// Any other error is fatal
IF_FAIL_GO(hr);

if (TestCandidateRefMatchesDef(pRequestedAssemblyName, pTPAAssembly->GetAssemblyName(), true /*tpaListAssembly*/))
Copy link
Member

Choose a reason for hiding this comment

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

And similarly here, if this fails we should trace that - look below for an example.

@@ -1775,27 +1775,27 @@ void SystemDomain::Init()
m_pSystemAssembly = NULL;

DWORD size = 0;

AppDomain* pAppDomain = ::GetAppDomain();
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? I don't see it used anywhere.

@@ -29,6 +29,7 @@
#include "gchandleutilities.h"
#include "../binder/inc/applicationcontext.hpp"
#include "rejit.h"
#include "bundle.h"
Copy link
Member

Choose a reason for hiding this comment

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

Given that there are no changes in appdomain.cpp do we need the include here?

@@ -281,10 +281,13 @@ void deps_resolver_t::setup_additional_probes(const std::vector<pal::string_t>&
* -- When servicing directories are looked up, look up only if the deps file marks the entry as serviceable.
* -- When a deps json based probe is performed, the deps entry's package name and version must match.
* -- When looking into a published dir, for rid specific assets lookup rid split folders; for non-rid assets lookup the layout dir.
* The path to the resolved file is returned in candidate out parameter
* If the candidate is embedded within the single-file bundle (rather than an actual file on disk), found_in_bundle will be set to true.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* If the candidate is embedded within the single-file bundle (rather than an actual file on disk), found_in_bundle will be set to true.
* If the candidate is embedded within the single-file bundle (rather than an actual file on disk), loaded_from_bundle will be set to true.

{
bIsFlatLayoutSuitable = FALSE;
}
bIsFlatLayoutSuitable = IsInBundle() || !bIsMappedLayoutSuitable;
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look right. We are completely discarding the previously computed value of the bIsFlatLayoutSuitable.

@swaroop-sridhar
Copy link
Contributor Author

Implemented few of the suggested changes, remaining to come shortly.

This change implements:

* Runtime changes necessary to load assemblies directly from the bundle:
    * Design notes about [Load from Bundle](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#peimage-loader)
    * Most of these changes are directly from dotnet/coreclr#26504 and dotnet/coreclr#26904

* Hostpolicy change to not add bundled assemblies to TPA list:
    * Design notes about [Dependency Resolution](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#dependency-resolution)
    * TBD (separately) items: Fix for hammer servicing dotnet#36031

Fixes dotnet#32822
@swaroop-sridhar swaroop-sridhar force-pushed the Run branch 2 times, most recently from 1b46420 to 7cc1384 Compare May 22, 2020 09:19
@swaroop-sridhar
Copy link
Contributor Author

@jkotas, @vitek-karas @janvorli Thanks for the comments. I've fixed these issues now.

@swaroop-sridhar swaroop-sridhar force-pushed the Run branch 2 times, most recently from 31bb483 to 368b189 Compare May 25, 2020 22:16
* Fix Assembly.ni.dll and Assembly.dll path usage.
* Remove unused full-path computation for corelib when loading from bundle.
* Add tracing when loading from bundle.
* Add bundle-probing for satellite assemblies.
* Adapt the BundleRename test to the .net5 scenario where assemblies are loaded from bundle.
@swaroop-sridhar swaroop-sridhar merged commit f9d3e6f into dotnet:master May 26, 2020
@swaroop-sridhar swaroop-sridhar deleted the Run branch May 26, 2020 21:10
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single-File: Implement loading assemblies from bundle
5 participants