Taritsyn/JavaScriptEngineSwitcher

Warning calling GarbageCollect on ChakraCore on Linux ends with StackOveflow in some cases.

Bobris opened this issue · 3 comments

This is not bug report, just want to share finding that calling GarbageCollect on ChakraCore is much more stack space hungry on Linux compared to Windows. Using 3.0.0 RC 1. It was pretty hard to find in complex app because vsdbg does not stop on this StackOverflow, same with debugger in Rider.

@Bobris can you share how you found the stackoverflow exception. I'm running into similar behavior without seeing any exceptions thrown. Did you use a special tool to catch this exception?

On Linux catching system access violations is complex thing - both .NetCore and Chakra setup their handlers - unfortunately they don't play nicely together (stack overflow is not really true reason). So first make sure that your code does not have any null dereference -> on Linux it just quickly crash your process (in some cases it will print stack overflow), on Windows it correctly throws NullReferenceException. That's reason we stopped using Chakra. I am using it in just relatively small application where I can be sure I will not make NullReferenceException bug and for example don't using Memory Mapped Files where you usually have to catch AccessViolationException. If some this kind of misterious crash happen on Linux, I debug it on Windows.
For details read: chakra-core/ChakraCore#5973

I hope that MS or somebody else will compile V8 on Linux+Mac and make .NetCore bindings. That's probably only way to have reliable fast JS JIT on Linux with .Net (hope they don't have same problem)