Skip to content

Fix crash when calling AssemblyLoadContext.Unload twice #91283

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

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

janvorli
Copy link
Member

The AssemblyLoadContext.InitiateUnload method was not handling multiple calls correctly. Instead of making the extra calls dummy, it was calling the native runtime helper PrepareForAssemblyLoadContextRelease again.

This change fixes it by simply ensuring that the runtime helper is called just once.

Close #91087

The AssemblyLoadContext.InitiateUnload method was not handling multiple
calls correctly. Instead of making the extra calls dummy, it was
calling the native runtime helper again.

This change fixes it by simply ensuring that the runtime helper is
called just once.
@jkotas
Copy link
Member

jkotas commented Aug 29, 2023

Can we add a test for this?

@ghost
Copy link

ghost commented Aug 29, 2023

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

The AssemblyLoadContext.InitiateUnload method was not handling multiple calls correctly. Instead of making the extra calls dummy, it was calling the native runtime helper PrepareForAssemblyLoadContextRelease again.

This change fixes it by simply ensuring that the runtime helper is called just once.

Close #91087

Author: janvorli
Assignees: janvorli
Labels:

area-AssemblyLoader-coreclr, area-VM-coreclr

Milestone: 8.0.0

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@janvorli janvorli merged commit e205d4b into dotnet:main Aug 30, 2023
@janvorli
Copy link
Member Author

/backport to release/8.0

@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6027997234

@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2023
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.

Calling AssemblyLoadContext.Unload multiple times causes fatal crash
2 participants