AccessViolationException
aaron-hardin opened this issue · 7 comments
I have seen several related issues on different repos but I have not seen this specific one, sorry if this is a duplicate. All the related issues seem to have been solved by updating packages, but I am running the latest I know of.
I am not seeing this issue consistently so I don't know how to reproduce reliably.
I am using:
- React.AspNet: 3.0.1
- JavaScriptEngineSwitcher.Core: 2.2.0
- MsieJavaScriptEngine: 2.1.2
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at MsieJavaScriptEngine.JsRt.Ie.IeNativeMethods.JsSetCurrentContext(IeJsContext context)
at MsieJavaScriptEngine.JsRt.Ie.ChakraIeJsRtJsEngine.<>c__DisplayClass30_0`1.<InvokeScript>b__0()
at MsieJavaScriptEngine.ScriptDispatcher.<>c__DisplayClass10_0`1.<Invoke>b__0()
at MsieJavaScriptEngine.ScriptDispatcher.StartThread()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
Hello, Aaron!
I have seen several related issues on different repos but I have not seen this specific one, sorry if this is a duplicate.
This is a completely new error. Previously, AccessViolationException
occurred only in CallFunction
method, but now it occurs in JsSetCurrentContext
method. Main problem is that it is very difficult to reproduce this error.
How often does this error occur?
We saw it 5 times the day I posted the issue, over about an hour.
I don't see it in any of the logs over the weekend though. The stack trace looks the same each time.
I have not seen the other AccessViolationException
since updating to the latest version of React.AspNet
/MsieJavaScriptEngine
I can get this consistently on Windows 7 and Windows Server 2012 R2. At the moment I am not seeing it on Windows 10.
Even when all of the React objects are set to render client side only I am seeing this.
I even tried to remove the MsieJsEngine after ReactJS.Net initializes it
JavaScriptEngineSwitcher.Core.JsEngineSwitcher.Instance.EngineFactories.Remove(JavaScriptEngineSwitcher.Msie.MsieJsEngine.EngineName);
None of this has fixed it. Unfortunately, VS2015 debugging profiling tools do not work properly on Windows 7 so I can't get any detailed information there.
I can get this consistently on Windows 7 and Windows Server 2012 R2.
What version of Internet Explorer installed on these machines?
At the moment I am not seeing it on Windows 10.
On Windows 10 installed a Microsoft Edge browser, and therefore the MSIE JavaScript Engine working in ChakraEdgeJsRt
mode.
I even tried to remove the MsieJsEngine after ReactJS.Net initializes it
JavaScriptEngineSwitcher.Core.JsEngineSwitcher.Instance.EngineFactories.Remove(JavaScriptEngineSwitcher.Msie.MsieJsEngine.EngineName);
I recommend you to read this comment. If you decide to abandon usage of the MSIE JavaScript Engine, then I recommend you to use the JavaScriptEngineSwitcher.ChakraCore.
What version of Internet Explorer installed on these machines?
My local machine and the server are both IE11
Registering ChakraCore seems to work for me. I had issues trying to do that previously, in case anyone else runs into similar issues, you need to add these packages to your project:
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x64
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x86
And add this to your Startup.cs
JsEngineSwitcher.Instance.EngineFactories.AddChakraCore();
You can close this issue if you want, I will be using ChakraCore unless I run into any issues with it, thanks!
I had issues trying to do that previously, in case anyone else runs into similar issues, you need to add these packages to your project:
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x64
- JavaScriptEngineSwitcher.ChakraCore.Native.win-x86
These packages are not needed for Linux and Mac users, therefore everyone should install only necessary packages. About this is written in the documentation and package description. My position about the React.NET is the following - reactjs/React.NET#360 (comment).
And add this to your Startup.cs
JsEngineSwitcher.Instance.EngineFactories.AddChakraCore();
I already have the corresponding line - https://github.com/Taritsyn/JavaScriptEngineSwitcher/blob/master/samples/JavaScriptEngineSwitcher.Sample.AspNetCore1.Mvc1/Startup.cs#L56.
Thanks for the additional information, I guess before I was only checking the React.NET repository.
I really appreciate all the help and the links to the documentation!