-
Notifications
You must be signed in to change notification settings - Fork 640
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
Getting Access Violation in after AppDomain cycle #383
Comments
Hi @davidebbo, I did not realize asp.net was cycling app domain rather than process. I can definitely see how spinning up a second app domain and running edge from there crashes the process. Node has an overarching assumption about being singleton per process (actually owning the process), so attempting to initialize it twice does not end well. When running Edge in a a CLR process there is a guard against double-initialization, but it is currently implemented in managed code: https://github.com/tjanczuk/edge/blob/master/src/double/dotnet/EdgeJs.cs#L59. I will need to see to how to refactor this logic to allow for multiple app domains. |
Ah, I see, it's a managed static so it doesn't survive appdomain cycles. But even if we were able to rely on a true process-wide global to avoid double init, would the V8 initialized in the first domain be able to work for the second domain? If it has any sort of back pointers to manage code objects living in the first domain, then it might be tricky. |
How does app domain recycling affect GC? At the time of recycling there may be some pending async calls issued from CLR to V8. If all managed objects in the recycled app domain are GCed without regard for those references, at the time V8 attempts to call back to CLR with completion we would likely see some AV. |
After the AppDomain shuts down, all objects that were in it are gone, and are probably GCed aggressively. However, if there is a cleanup sequence that can cleanly disconnect everything from the AppDomain, we can make use of the Or even without building this pattern in Edge, if there was some way to call into Edge to explicitly tell it to disconnect, then the Web App author could call it themselves on AppDomain shutdown. |
There is any workaround? This can be a really big problem... |
@tjanczuk |
When using Edge.js in ASP.NET, it works fine in the initial AppDomain. But if you then touch web.config or do some other action that cause an AppDomain cycle, it crashes on the next request.
This happens with a minimal one page ASP.NET app that uses Edge in the simplest way. Full repro can be found on https://github.com/davidebbo-test/EdgeCrashRepro.
The crash stack looks like this:
One theory is that there is some process global state that causes some lifetime management issue across AppDomains.
The text was updated successfully, but these errors were encountered: