"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." #7

Daniel15 opened this Issue May 24, 2016 · 21 comments


None yet

7 participants


Do you know what would cause this exception? I see it sporadically and occasionally get reports of people encountering it in ReactJS.NET

An unhandled exception of type 'System.AccessViolationException' occurred in MsieJavaScriptEngine.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

   at MsieJavaScriptEngine.JsRt.Edge.EdgeNativeMethods.JsCallFunction(EdgeJsValue function, EdgeJsValue[] arguments, UInt16 argumentCount, EdgeJsValue& result)
   at MsieJavaScriptEngine.JsRt.Edge.EdgeJsValue.CallFunction(EdgeJsValue[] arguments)
   at MsieJavaScriptEngine.JsRt.Edge.ChakraEdgeJsRtJsEngine.<>c__DisplayClassc.<CallFunction>b__b()
   at MsieJavaScriptEngine.JsRt.Edge.ChakraEdgeJsRtJsEngine.InvokeScript[T](Func`1 func)
   at MsieJavaScriptEngine.JsRt.Edge.ChakraEdgeJsRtJsEngine.CallFunction(String functionName, Object[] args)
   at MsieJavaScriptEngine.MsieJsEngine.CallFunction(String functionName, Object[] args)
   at JavaScriptEngineSwitcher.Msie.MsieJsEngine.InnerCallFunction(String functionName, Object[] args)
   at JavaScriptEngineSwitcher.Msie.MsieJsEngine.InnerCallFunction[T](String functionName, Object[] args)
   at JavaScriptEngineSwitcher.Core.JsEngineBase.CallFunction[T](String functionName, Object[] args)
   at React.JavaScriptEngineUtils.CallFunctionReturningJson[T](IJsEngine engine, String function, Object[] args) in C:\src\ReactJS.NET\src\React.Core\JavaScriptEngineUtils.cs:line 89
   at React.ReactEnvironment.ExecuteWithBabel[T](String function, Object[] args) in C:\src\ReactJS.NET\src\React.Core\ReactEnvironment.cs:line 323
   at React.Babel.TransformWithSourceMap(String input, String filename) in C:\src\ReactJS.NET\src\React.Core\Babel.cs:line 287
   at React.Babel.TransformWithHeader(String filename, String contents, String hash) in C:\src\ReactJS.NET\src\React.Core\Babel.cs:line 225
   at React.Babel.TransformFileWithSourceMap(String filename, Boolean forceGenerateSourceMap) in C:\src\ReactJS.NET\src\React.Core\Babel.cs:line 126
   at React.Babel.TransformFile(String filename) in C:\src\ReactJS.NET\src\React.Core\Babel.cs:line 89
   at React.ReactEnvironment.EnsureUserScriptsLoaded() in C:\src\ReactJS.NET\src\React.Core\ReactEnvironment.cs:line 165
   at React.ReactEnvironment.CreateComponent[T](String componentName, T props, String containerId, Boolean clientOnly) in C:\src\ReactJS.NET\src\React.Core\ReactEnvironment.cs:line 265
   at React.AspNet.HtmlHelperExtensions.React[T](IHtmlHelper htmlHelper, String componentName, T props, String htmlTag, String containerId, Boolean clientOnly, Boolean serverOnly, String containerClass) in C:\src\ReactJS.NET\src\React.AspNet\HtmlHelperExtensions.cs:line 86
   at Asp._Views_Home_Index_cshtml.<ExecuteAsync>d__25.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Asp._Views_Home_Index_cshtml.ExecuteAsync()
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)

Hello, Daniel15!

You use the EmbedHostObject and EmbedHostType methods?


Which version of the MsieJavaScriptEngine causes this error?

Daniel15 commented May 24, 2016 edited

I'm not using EmbedHostObject or EmbedHostType. This was just happening on a regular CallFunction method call.

I'm using JavaScriptEngineSwitcher.Msie 1.5.0 with MsieJavaScriptEngine 1.7.0.

I haven't yet had time to try and get a standalone repro case so I'm not sure exactly what's causing it, sorry :( I'm seeing it when running React.Samples.Mvc6 from ReactJS.NET.


I faced similar errors when working on the LibSass Host for .NET project. Such errors usually occur, when from the unmanaged code is access to member of the managed object, that has been garbage-collected. But since you don't use the EmbedHostObject and EmbedHostType methods, I can not understand how this happens.


This error occurred when working with ASP.NET 5 RC 1?


@Daniel15 just to be clear. You see this when debugging in VS? And it is not when u have "break on all exceptions" turned on. Does it ever happen on the first debug after starting VS, ie before u have done a stop and start again? I am just ruling out a couple of theories


I've only seen it while working with ASP.NET 5 RC1 and RC2, but I haven't verified that it doesn't occur in other scenarios too. Someone else noticed the same thing when upgrading ReactJS.NET from ASP.NET 5 RC1 to RC2: reactjs/React.NET#268

You see this when debugging in VS?


Does it ever happen on the first debug after starting VS

I see it as soon as I start my test project. It sometimes runs fine after hitting this exception though (ie. future page loads are fine).

If I get some free time, I'll try to narrow down the cause and see if I can figure out exactly what is causing it. Help is appreciated though :)


This all looks like a errors in garbage collector of DotNet CLI.

defcon84 commented Aug 1, 2016

Is there any information / progress on this?

Taritsyn commented Aug 1, 2016

In this week I will begin migration of the JavaScript Engine Switcher and the MSIE JavaScript Engine to .NET Core.

It is possible, that this problem will solve itself in process of migration.


It might have something to do with this: Microsoft/Chakra-Samples#4


Try upgrade to version 1.7.2.


The issue persists with 1.7.2.
error log: http://pastebin.com/uLqzpJm3


Then you need to wait for release of version 2.0. I will begin to develop a new version after release of first alpha of the JavaScript Engine Switcher version 2.0.

jamsoft commented Sep 22, 2016

I've just encountered this error as I'm working through this tutorial my first ReactJS.Net project. The full error I see is:

System.AccessViolationException was unhandled
Message: An unhandled exception of type 'System.AccessViolationException' occurred in MsieJavaScriptEngine.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


@jamsoft What version of ASP.NET you use?

Taritsyn commented Dec 2, 2016

Try upgrade to version 2.0.2.


This seems to be an issue with .NET Core, rather than ASP.NET Core. I've written more here: reactjs/React.NET#358 (comment).

Taritsyn commented Dec 5, 2016

Has anyone is missing this error after updating to version 2.0.2?

lhmiranda commented Dec 23, 2016 edited

I was having the same issue while implementing server side rendering using ReactJS.net with ASP.NET Core (following the official tutorial). I solved the problem by adding MsieJavaScriptEngine 2.1.0 to my project.


Hello, LHMiranda!

Thanks for information! Now I can close this issue.

@Taritsyn Taritsyn closed this Dec 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment