Skip to content

System.AccessViolationException #398

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

Closed
andreymir opened this issue Apr 16, 2017 · 7 comments
Closed

System.AccessViolationException #398

andreymir opened this issue Apr 16, 2017 · 7 comments

Comments

@andreymir
Copy link

andreymir commented Apr 16, 2017

Not sure whether it is a React.NET or ClearScript issue. I'm trying to run my application in a docker container. At strartup it crashes with the System.AccessViolationException exception.

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at V8Context.Create(SharedPtr<V8Isolate>* , StdString* , Boolean , Boolean , Int32 )
   at Microsoft.ClearScript.V8.V8ContextProxyImpl..ctor(V8IsolateProxy gcIsolateProxy, String gcName, Boolean enableDebugging, Boolean disableGlobalMembers, Int32 debugPort)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Microsoft.ClearScript.V8.V8Proxy.CreateImpl[T](Object[] args)
   at Microsoft.ClearScript.V8.V8ScriptEngine..ctor(V8Runtime runtime, String name, V8RuntimeConstraints constraints, V8ScriptEngineFlags flags, Int32 debugPort)
   at JavaScriptEngineSwitcher.V8.V8JsEngine..ctor(V8Settings settings)
   at JavaScriptEngineSwitcher.V8.V8JsEngineFactory.CreateEngine()
   at React.JavaScriptEngineFactory.GetFactory(JsEngineSwitcher jsEngineSwitcher, Boolean allowMsie)
   at React.JavaScriptEngineFactory..ctor(JsEngineSwitcher jsEngineSwitcher, IReactSiteConfiguration config, IFileSystem fileSystem)
   at lambda_method(Closure , Object[] )
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.SingletonFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.CustomObjectLifetimeFactory.GetObject(Type requestedType, TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options)
   at React.TinyIoC.TinyIoCContainer.Resolve[ResolveType]()
   at React.AspNet.HtmlHelperExtensions.get_Environment()
   at React.AspNet.HtmlHelperExtensions.React[T](IHtmlHelper htmlHelper, String componentName, T props, String htmlTag, String containerId, Boolean clientOnly, Boolean serverOnly, String containerClass)
   at AspNetCore._Views_Site_Menu_cshtml.<ExecuteAsync>d__33.MoveNext() in /Views/Site/Menu.cshtml:line 3
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at AspNetCore._Views_Site_Menu_cshtml.ExecuteAsync()

Without container it is runs fine.

@andreymir
Copy link
Author

Posted the issue to ClearScript https://clearscript.codeplex.com/workitem/120

@Taritsyn
Copy link
Contributor

Hello, Andrey!

What versions of the JavaScriptEngineSwitcher.V8, JavaScriptEngineSwitcher.V8.Native.win-x86 and JavaScriptEngineSwitcher.V8.Native.win-x64 packages do you use?

@andreymir
Copy link
Author

andreymir commented Apr 17, 2017

Hi Andrey!
Thanks for your help! Initially I tried with older version but it has the same issue. Now I'm using the latest version available 2.2.0.
image

@Taritsyn
Copy link
Contributor

Now I'm using the latest version available 2.2.0.

This error no longer occurs?

@andreymir
Copy link
Author

No, still have the same exception.
However, there is a theory it could be a memory limit issue. Someone suggested that V8 could crash if it could not allocate enough memory

Another possibility is that the V8 runtime is too constrained to complete startup. Are you using V8RuntimeConstraints to specify memory usage limits?
Also, could it be that Docker is imposing various limits on your application?
https://clearscript.codeplex.com/workitem/120

I'm going to check today if there are options in docker related to memory and will see if it fixes the issue.

@Taritsyn
Copy link
Contributor

Try to register the V8JsEngine manually.

Are you using V8RuntimeConstraints to specify memory usage limits?

I recommend you also read the “Registration of JS engines” and “JS Engine Switcher: V8” sections of the JavaScript Engine Switcher's documentation.

If you plan to use ASP.NET Core in your projects, then try the JavaScriptEngineSwitcher.ChakraCore.

@andreymir
Copy link
Author

I think we could close the issue. I did some testing today and it seems that it was a memory limit issue.

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

No branches or pull requests

2 participants