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

[release/6.0-preview7] [loader] Call managed resolving events for the default ALC #56421

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jul 27, 2021

Backport of #56398 to release/6.0-preview7

/cc @lambdageek

Customer Impact

Code using assembly load contexts will get a null reference exception when accessing the default ALC.

Testing

Manual testing.

Risk

Moderate. This is changing some code that runs early during app startup. On Android, the embedder host uses the mono API to add hooks that run when managed and native libraries are loaded. This PR could cause those hooks to behave differently, potentially leading to crashes at startup. However it should fail in pretty much every CI test in Xamarin.Android, so a mistake should be easily detectable.

Refine the work in
f70b5b7

The issue is that even if we know that the ALC gchandle points to null in
native, we can't automatically skip the call to the managed resolving
event (for native library, for example) because the native event is indirectly
responsible for creating the default ALC managed object.

Instead, check in native if the gchandle is equal to the default ALC's
gchandle (which is initially allocated with a null target) and if so pass
IntPtr.Zero to the managed code, which will call
`AssemblyLoadContext.GEtAssemblyLoadContext (IntPtr gch)` which in turn will
construct the managed object for the default ALC.

Fixes #55921
@ghost
Copy link

ghost commented Jul 27, 2021

Tagging subscribers to this area:
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #56398 to release/6.0-preview7

/cc @lambdageek

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-AssemblyLoader-mono

Milestone: -

@lambdageek lambdageek added the Servicing-consider Issue for next servicing release review label Jul 27, 2021
@steveisok
Copy link
Member

I don't think we can take this change as it's too late for P7.

@steveisok steveisok closed this Jul 29, 2021
@akoeplinger akoeplinger deleted the backport/pr-56398-to-release/6.0-preview7 branch August 2, 2021 10:00
@ghost ghost locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-AssemblyLoader-mono Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants