Open vms20591 opened 5 years ago
thanks for your feedback, I'll look at it soon.
hi, I tried it on my windows 10 laptop, but I can't repro this issue. however I found a related issue at https://github.com/Microsoft/ChakraCore/issues/5973 , maybe this could help.
Hi,
Thanks for the update. No issues on Windows 10, it occurs on Linux and Mac OS. I did look at the above issue and built ChakraCore with the changes mentioned. I don't get stack smashed error, but SIGSEV
instead.
So, wondering if anything can be done from ChakraCore.NET for this.
I'm do some test later, but not sure if I could fix it at the wrapper side.
@JohnMasen Any progress on it?
Sorry for late response. SIGSEV seems shared the same root cause of "stack smashing" . can you please try update to the latest chakracore and see if the problem still exists?
I think I may found the root cause. SIGSEV exception hides the real exception which is NullReferenceException, it is triggered by javascript calls to an CLR object which has been disposed. the root cause is chakracore context begins to dispose before the promise callback is triggered.
Chakracore will track the object reference and keep it alive until the value has been garbage collected in chakracore context. ideally your object will live as long as js code lives.
However chakracore uses separated threads to run the "main" thread and "promise" thread. it is possible the main thread begins to GC before the promise thread calls back. this happens when context object is no longer used and .NET GC begins to dispose it. As the "promise" thread was referenced by "main" thread object, GC will always dispose the "main" thread first.
solution : keep the context alive until promise method is completed.
In a context with "promise" code, there's no guarantee when the js code will finish, I didn't find a good solution in the wrapper level without memory leak. it is suggested keep the context alive until all works finished.
you can find the unit test "PromiseCallFromJS" is checking a flag variable to keep the context alive until promise call is completed. although it was designed to collect the result from promise call, it becomes a workaround of this issue. I just remember I got the same problem when I was testing the code at early stage.
another way is a WorkDone() callback to host in your js code, this soltuion doesn't require host keep checking the flag variable. however it may turns your code a bit more complex.
Hi,
When running any JS code that has promises in them like the following example, a
stack smashing detected
error is thrown and program crashes.I have created a repro project here.
Tried analyzing the coredump using gdb and got the following,
Details:
Edit: