Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

node: AssemblyLoadContext.Default.Unloading might not be reliable for thorough disposition #816

Closed
Qiao-Jin opened this issue Aug 17, 2021 · 1 comment
Labels

Comments

@Qiao-Jin
Copy link
Contributor

Qiao-Jin commented Aug 17, 2021

In these lines we set up Unloading events which are executed when user closes neo-cli.

public virtual void OnStart(string[] args)
{
// Register sigterm event handler
AssemblyLoadContext.Default.Unloading += SigTermEventHandler;
// Register sigint event handler
Console.CancelKeyPress += CancelHandler;
}

However there might be problems in this strategy. Unless user chooses to close cli by typing "exit" command, other ways such as directly clicking "close" button will leave only no more than 2 seconds for this event. That means, if disposition actions take longer than this time period, whole process will be shut down before everything disposed gracefully.

Currently there seems nothing that must be disposed before shutting down (even DB), but still this is some vulnerability easy to be neglected.

https://docs.microsoft.com/en-us/dotnet/api/system.appdomain.processexit?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.AppDomain.ProcessExit)%3Bk(SolutionItemsProject)%3Bk(SolutionItemsProject)%3Bk(SolutionItemsProject)%3Bk(DevLang-csharp)%26rd%3Dtrue&view=net-5.0

@shargon shargon changed the title AssemblyLoadContext.Default.Unloading might not be reliable for thorough disposition node: AssemblyLoadContext.Default.Unloading might not be reliable for thorough disposition Dec 5, 2023
@shargon shargon added the node label Dec 5, 2023
@shargon
Copy link
Member

shargon commented Dec 5, 2023

Old, if remains, please re-open

@shargon shargon closed this as completed Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants