Multiple JsRuntimes crashe if first is not dropped before a second is created and ran
In my application, I want an
op2
to take in a function which will be stored in a struct as a Global<v8::Function>
. Later this function will be called. This issue is the application crashes with Memory Access Violation
. However, this only occurs on the second instance of the JsRuntime. Additionally this doesn't happen for the first few call, which leads me to believe it is something with the handle be garbage collected.6 Replies
Here's a simplified source with
[...]
to show omitted code:
(had to split it up due to message length limit)I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems like there might be an issue with the way the
Global<v8::Function>
handle is being managed across different instances of JsRuntime
.
Without seeing the actual code, it's difficult to provide a precise solution, but here are a couple of general points you might want to consider:
1. Ensure that you are properly managing the lifetime of the Global<v8::Function>
handle. If it's being garbage collected prematurely, you might need to look into how you're maintaining references to it.
2. Check if you are correctly creating and disposing of JsRuntime
instances. Improper handling of these instances could lead to memory access violations.
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. It might also be helpful to review the V8 embedding documentation or seek assistance from the community if the problem persists.After updating the call to instead get the function from the global scope instead of storing it, it still crashes.
Maybe it has to do with creating multiple Js runtimes...
It does seem like it could be the isolate
I found a fix but I don't understand why it fixes it. If I manually drop first runtime before creating a second, There is no longer a crash.
If anyone has any incite into why this happens, it would be helpful