Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Violation Exception when running JSX handler in Visual Studio debugging session #28

Closed
paulirwin opened this issue Jun 25, 2014 · 29 comments
Labels

Comments

@paulirwin
Copy link

Please note that this is not a consistently reproducible issue AFAICT.

Occasionally, and this seems to be about on average once an hour or so during active development, when going through this process (my normal react.js dev workflow) it results in a catastrophic Access Violation Exception:

  1. Start the Visual Studio 2013 debugger for my ASP.NET MVC project that uses React.NET.
  2. Make some changes to my JSX file in Sublime. Hit Save.
  3. Go over to Chrome, hit refresh. This requests the JSX file from the React.NET JSX handler again.
  4. If successful, the JSX handler will return the compiled JS, then I'll test it and probably go back to step 2 again, keeping the same debugger session active. But occasionally here I'll get Visual Studio popping up saying that the "Unknown Handler" had an Access Violation Exception. After clicking OK, the process crashes, and Visual Studio stops debugging.
  5. After a crash like this, without modifying the JSX file, I'll re-start the debugging session in VS, call the .jsx URL again executing the handler, and it will compile the JS just fine (meaning there's nothing wrong with the JSX itself).

Due to the obscure nature of the exception, that it says "Unknown Handler", and that I have no call stack or target site, I can't give any further information about the exception itself. I assume it is occurring in the MSIE integration layer, but that is just a guess. I also have yet to deploy this app to any kind of production environment, so this is at least a developer environment / IIS Express issue. I can not confirm if this does or does not happen using full IIS.

While I can't do anything explicitly to reproduce this, I can say that this happens at least under this criteria:

  • Keeping the Visual Studio debugging session active across multiple JSX file changes
  • This exception has not yet occurred on the first load -- it has always been after I've saved the JSX file a couple times and reloaded the page/called the JSX handler again a few times.
  • If it matters, I am not editing the file in Visual Studio (using Sublime 3)

And, if it's relevant (due to the MSIE engine), here's my system info:

  • Windows 8.1 update
  • IE 11.0.9600.17126

If you would like me to try anything explicitly on my machine to try to reproduce this issue, let me know and I'd be happy to help. Also, I'm interested to know if anyone else has encountered this issue.

@Daniel15
Copy link
Member

Are you on React.Core 1.0 or 1.0.1? If only on 1.0, can you please try upgrading to 1.0.1 and see if the same issue occurs? NuGet seems to like only installing 1.0 even though 1.0.1 is available.

@paulirwin
Copy link
Author

Ah ha, very strange. It did install 1.0.0 along with older versions of the dependencies even though I only installed it a few days ago, well after 1.0.1 came out, like you said. I will upgrade React.Core to 1.0.1, as well as the latest versions of JavaScriptEngineSwitcher.Jint, JavaScriptEngineSwitcher.Msie, and MsieJavaScriptEngine, and I'll post back here and let you know if it occurs again, or if it seems to be resolved after enough time testing it, I'll post that as well. Thanks for responding so quickly!

@Daniel15
Copy link
Member

I just modified the NuGet package to hide 1.0, hopefully that means NuGet will install 1.0.1 (but I don't have access to a Windows machine at the moment so can't test it).

Let me know if upgrading JavaScriptEngineSwitcher.Msie or MsieJavaScriptEngine fixes it, in which case I'll bump the version number requirement. I have a feeling it's in the MSIE engine somewhere. I've been meaning to try V8 on Windows but I had a lot of issues getting the version required by VroomJS to compile on Windows (works fine on Linux though, I use it in production on a pretty simple page with no issues).

Do you have any debug info at all, even a single stack frame?

@paulirwin
Copy link
Author

I just encountered the AccessViolationException again on the latest versions of all the NuGet packages. No debug info, no call stack, nothing. I agree that it is most likely in the IE engine. I guess I could try Jint and see if that helps?

@paulirwin
Copy link
Author

I still haven't switched over to Jint yet so this is still MSIE, and I just got it again. Here's the full message:

An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.

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

And that's all it gives, no ability to see any other details of the exception in VS. During this, VS shows a "Code not running" tab and there's nothing in the call stack window. If I hit Continue (F5), the process shuts down and VS stops debugging.

I'm going to try removing MSIE in the web.config and use Jint and see if it happens again -- I'm guessing it won't since Jint is managed code.

@paulirwin
Copy link
Author

I should also note that this was with a completely different application/solution than when I was getting it before, with completely different, unrelated JSX files, so it doesn't seem to be anything related to my project.

@Daniel15 Daniel15 added the bug label Jun 28, 2014
@Daniel15
Copy link
Member

I'm having trouble replicating this on my system (Windows 8.1 64-bit, IE 11.0.9600.16521 running in VMWare Fusion). Are you on 64-bit or 32-bit? Can you replicate this issue if you build from source (instructions here) and run the included "React.Samples.Mvc4"?

Switching to Jint in the web.config won't actually work as I'm not using the JS switcher config. ReactJS.NET has its own config. Unfortunately Jint doesn't support JSX compilation at all since the stack gets too large for it to handle :(

@paulirwin
Copy link
Author

64-bit, IE 11 on 8.1. I'll try building from source and running the samples, but I'll have to modify the samples to really test it out, as it almost never occurs on the first hit in the app, it's usually after modifying the JSX files multiple times while debugging.

Looking at the "has its own config" link to the source above, I see that you're using ChakraActiveScript. Have you tried it with ChakraJsRt mode? Just curious to know if there's a difference.

@paulirwin
Copy link
Author

FYI - My colleague has now also received this exception on his machine, which is also 8.1 with IE 11. So this is not an isolated issue to my machine.

@Daniel15
Copy link
Member

Daniel15 commented Jul 9, 2014

I did try ChakraJsRt initially but it failed since it couldn't handle the large Esprima stacks (JSXTransformer uses Esprima for parsing) so I had to stop using it. Could you please send through a small project that replicates the issue? I'm about to go on vacation but I can take a look once I'm back. Thanks!

@jlchmura
Copy link
Contributor

jlchmura commented Aug 4, 2014

I have the same issue happening, though my debugger is not attached at the time, but I am building in Debug mode.

VS2013 using iisexpress
64-bit Win7
Chrome

I'll make some changes to a JSX inside VS and save. When reloading the page in Chrome, IISExpress crashes with an access violation exception. It doesn't happen every time. Some times I can go 10 or more saves without crash, while other times I'll get two in a row.

@paulirwin
Copy link
Author

Thanks @jlchmura, glad it's not just us! Also, an update, I have confirmed that our entire dev team gets this exception regularly. Hopefully someone can figure out what's happening!

@Daniel15
Copy link
Member

Daniel15 commented Aug 9, 2014

It's interesting that I haven't been able to repro this :(

I'm using a virtual machine though (in VMWare Fusion). Maybe I should try it on a 'real' machine and see if I get the same error.

@jlchmura
Copy link
Contributor

Another interesting bit of information:

I created a Debug build of the React.NET libraries (just pulled the source this morning) and switched my project to use those. IIS crashes have stopped. Did a Release build and they are back.

@jlchmura
Copy link
Contributor

Update on this.. my previous pull request prevented the crash, but did not solve the cause. @Daniel15 - DisposeAll was being called and the environment was properly being disposed even without my change. However, I was finally able to catch the exception (below) which was being thrown in FileCacheHash. MD5.ComputeHash is not thread-safe but FileCacheHash was being registered as a singleton.

This also solves the seemingly random http 500's being thrown by the jsx handler.

I'll submit another pull request with the fix.

System.ObjectDisposedException was unhandled by user code
  HResult=-2146232798
  Message=Safe handle has been closed
  Source=mscorlib
  ObjectName=""
  StackTrace:
       at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
       at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
       at System.Security.Cryptography.Utils.HashData(SafeHashHandle hHash, Byte[] data, Int32 cbData, Int32 ibStart, Int32 cbSize)
       at System.Security.Cryptography.MD5CryptoServiceProvider.HashCore(Byte[] rgb, Int32 ibStart, Int32 cbSize)
       at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer)
       at React.FileCacheHash.CalculateHash(String input) in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React\FileCacheHash.cs:line 39
       at React.JsxTransformer.<>c__DisplayClass1.<TransformJsxFile>b__0() in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React\JsxTransformer.cs:line 87
       at React.Web.AspNetCache.GetOrInsert[T](String key, TimeSpan slidingExpiration, Func`1 getData, IEnumerable`1 cacheDependencyFiles, IEnumerable`1 cacheDependencyKeys) in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React.Web\AspNetCache.cs:line 71
       at React.JsxTransformer.TransformJsxFile(String filename, Nullable`1 useHarmony) in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React\JsxTransformer.cs:line 79
       at React.Web.JsxHandler.Execute() in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React.Web\JsxHandler.cs:line 51
       at React.Web.JsxHandlerFactory.ProcessRequest(HttpContext context) in c:\Users\jchmura\Documents\GitHub\ChmuraEcon\React.NET\src\React.Web\JsxHandlerFactory.cs:line 26
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  InnerException: 

jlchmura added a commit to ChmuraEcon/React.NET that referenced this issue Aug 18, 2014
Fixing ObjectDisposedException thrown by MD5 provider being used in a
non-threadsafe context.
@paulirwin
Copy link
Author

@jlchmura Is that the cause of the Access Violation Exception?

@jlchmura
Copy link
Contributor

@paulirwin Yes, I believe so. Our dev machines only have a few hours of runtime with my latest build, but so far nobody has run in to the access violation. Typically we would have hit it several times already. I'd be curious to hear if it solves the issue in your environment too.

Daniel15 added a commit that referenced this issue Aug 19, 2014
@Daniel15
Copy link
Member

Thanks for your help @jlchmura!

@paulirwin - I've just merged @jlchmura's change so it should be available on the dev package repository once the build server picks it up. You can try out that package and let me know if you still experience the issue or if it fixes it for you.

@Daniel15
Copy link
Member

I'm going to close this as I believe @jlchmura's fix should fix the issue. This fix is available in version 1.1.0 and I've credited @jlchmura in the changelog. Thanks!

@paulirwin
Copy link
Author

FYI - it seems @jlchmura's fix was at least partially unrelated to this issue, as my team of 4 developers each still get this exception daily when using the MSIE engine. We switched to the V8 engine and so far we haven't gotten the exception -- I'll update here if we do, but so far so good. There definitely still seems to be a problem with the MSIE engine.

@Daniel15
Copy link
Member

Thanks @paulirwin - I'll try to investigate the MSIE issues further, but at least you can use V8 to work around the issue :)

Are you still seeing this issue on ReactJS.NET 1.3?

@paulirwin
Copy link
Author

No, our team has not seen the exception in the last couple weeks since switching the Web.config to use the V8 engine, and we are on ReactJS.NET 1.3.0.

To be honest, should this project consider adopting V8 as the preferred engine? It seems to work rather well, there is clear industry support for V8, and I like that ClearScript V8 packages the V8 DLLs along with your project instead of depending on MSIE on the web server. I would encourage everyone using this project to try out the V8 engine, and if after a while there aren't any issues, use that as preferred with MSIE as a fallback.

@Daniel15
Copy link
Member

I originally used MSIE because it doesn't require any additional unmanaged
DLL files.

I think I'll split MSIE support into a separate package and make people
explicitly choose which engine they want to use (ie. Don't prefer any
particular engine by default).

Sent from my mobile.
On Dec 20, 2014 2:10 AM, "Paul Irwin" notifications@github.com wrote:

No, our team has not seen the exception in the last couple weeks since
switching the Web.config to use the V8 engine, and we are on ReactJS.NET
1.3.0.

To be honest, should this project consider adopting V8 as the preferred
engine? It seems to work rather well, there is clear industry support for
V8, and I like that ClearScript V8 packages the V8 DLLs along with your
project instead of depending on MSIE on the web server. I would
encourage everyone using this project to try out the V8 engine, and if
after a while there aren't any issues, use that as preferred with MSIE as a
fallback.

Reply to this email directly or view it on GitHub
#28 (comment).

@Shreeyam
Copy link

Shreeyam commented Jun 4, 2016

Any update on this? I get a System.AccessViolationError consistently when running my application in IIS 10, but not when debugging using IIS Express.

Edit: This is using MsieJavaScriptEngine

@beruic
Copy link

beruic commented Jun 8, 2016

I get this consistently in VisualStudio 2015 using both IIS Express and running the program + running it from console.

I use the sample project from https://github.com/reactjs/React.NET/tree/master/src/React.Sample.Mvc6. Only change I made is in project.json where I put

"React.Core": "2.4.0",
"React.AspNet": "2.4.0"

instead of the existing dependencies.

@mwethington
Copy link

We get crashes all the time in IIS even with V8. Same stuff.

@Daniel15
Copy link
Member

@mwethington - Could you please provide a stack trace? So far I've only seen this error with the MSIE JS engine in the stack trace.

@paulirwin
Copy link
Author

Original issue creator here. Wow, I can't believe it's been over 2 years since I originally filed this! Unfortunately I can't help validate with the latest changes as we no longer use this library, we now use either Webpack/Babel or the TypeScript compiler to transform our JSX. But I can say that in the last weeks that we were using this library we did still encounter this issue from time to time with V8 as our only engine in our web.config file.

@rickywang1981
Copy link

rickywang1981 commented Sep 17, 2016

Hi Daniel: we also encounter AccessViolationException with V8 from time to time. The error cannot be catched by ASP.NET. Could you look into this urgent issue? This is error log while ASP.NET crashes:

Version=1
EventType=CLR20r3
EventTime=131185943235051992
ReportType=2
Consent=1
ReportIdentifier=d7a3d85c-7cde-11e6-80d8-005056853a8a
IntegratorReportIdentifier=d7a3d85b-7cde-11e6-80d8-005056853a8a
WOW64=1
NsAppName=w3wp.exe
Response.type=4
Sig[0].Name=Problem Signature 01
Sig[0].Value=w3wp.exe
Sig[1].Name=Problem Signature 02
Sig[1].Value=8.5.9600.16384
Sig[2].Name=Problem Signature 03
Sig[2].Value=52157ba0
Sig[3].Name=Problem Signature 04
Sig[3].Value=ClearScriptV8-32
Sig[4].Name=Problem Signature 05
Sig[4].Value=5.4.5.0
Sig[5].Name=Problem Signature 06
Sig[5].Value=56e184c1
Sig[6].Name=Problem Signature 07
Sig[6].Value=f7
Sig[7].Name=Problem Signature 08
Sig[7].Value=4f
Sig[8].Name=Problem Signature 09
Sig[8].Value=System.AccessViolationException
DynamicSig[1].Name=OS Version
DynamicSig[1].Value=6.3.9600.2.0.0.272.7
DynamicSig[2].Name=Locale ID
DynamicSig[2].Value=1033
DynamicSig[22].Name=Additional Information 1
DynamicSig[22].Value=f4b8
DynamicSig[23].Name=Additional Information 2
DynamicSig[23].Value=f4b83f39e04b97afc15f0c96e3a7c9c3
DynamicSig[24].Name=Additional Information 3
DynamicSig[24].Value=00a3
DynamicSig[25].Name=Additional Information 4
DynamicSig[25].Value=00a37bc75e5534558a731b6ec5129823
UI[2]=C:\Windows\SysWOW64\inetsrv\w3wp.exe
UI[5]=Check online for a solution (recommended)
UI[6]=Check for a solution later (recommended)
UI[7]=Close
UI[8]=IIS Worker Process stopped working and was closed
UI[9]=A problem caused the application to stop working correctly. Windows will notify you if a solution is available.
UI[10]=&Close
LoadedModule[0]=C:\Windows\SysWOW64\inetsrv\w3wp.exe
...
...
LoadedModule[172]=root\bin\ClearScript.V8\ClearScriptV8-32.dll
LoadedModule[173]=root\bin\ClearScript.V8\v8-ia32.dll
LoadedModule[174]=C:\Windows\SYSTEM32\MSVCP120.dll
LoadedModule[175]=C:\Windows\SYSTEM32\MSVCR120.dll
LoadedModule[176]=C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrcompression.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants