This project has moved. For the latest updates, please go here.
2

Closed

[BUG] Hang on application pool recycle

description

Hi,

Using React.NET 3.0.1 which uses ClearScript.V8 5.4.8 following hang is observed on recycling application pool
.NET Call Stack


.SharedPtr.Release(SharedPtr*)+d7 
[[InlinedCallFrame] (.Decrement)] .RefCount.Decrement(RefCount*) 
Microsoft.ClearScript.V8.V8ContextProxyImpl.!V8ContextProxyImpl()+4e 
Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean)+1f 
[[DebuggerU2MCatchHandlerFrame]] 
[[ContextTransitionFrame]] 
[[GCFrame]] 
[[DebuggerU2MCatchHandlerFrame]] 

Full Call Stack

ntdll!NtWaitForSingleObject+14 
KERNELBASE!WaitForSingleObjectEx+8f 
v8_x64!v8::Extension::dependencies+329ac 
v8_x64!v8::ExternalResourceVisitor::VisitExternalString+28187 
v8_x64!v8::ExternalResourceVisitor::VisitExternalString+1a3 
v8_x64!v8::ExternalResourceVisitor::VisitExternalString+533b 
ClearScriptV8_64+14216 
ClearScriptV8_64+120e4 
ClearScriptV8_64+13e3f 
ClearScriptV8_64+50a8 
<Module>.SharedPtr<V8Context>.Release(SharedPtr<V8Context>*)+d7 
[[InlinedCallFrame] (<Module>.Decrement)] <Module>.RefCount.Decrement(RefCount*) 
Microsoft.ClearScript.V8.V8ContextProxyImpl.!V8ContextProxyImpl()+4e 
Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean)+1f 
clr!FastCallFinalizeWorker+6 
clr!ETW::GCLog::SendFinalizeObjectEvent+c9 
clr!MethodTable::CallFinalizer+b5 
clr!CallFinalizer+5e 
clr!FinalizerThread::DoOneFinalization+95 
clr!FinalizerThread::FinalizeAllObjects+133 
clr!FinalizerThread::FinalizeAllObjects_Wrapper+18 
clr!Frame::Push+59 
clr!PEDecoder::GetNativeCodeManagerTable+170 
clr!PEDecoder::GetNativeCodeManagerTable+99 
[[DebuggerU2MCatchHandlerFrame]] 
clr!Thread::ShouldChangeAbortToUnload+45 
clr!Thread::DoADCallBack+109 
[[ContextTransitionFrame]] 
clr!Frame::Push+a2 
clr!FinalizerThread::DoOneFinalization+1f9 
[[GCFrame]] 
clr!FinalizerThread::FinalizeAllObjects+133 
clr!FinalizerThread::FinalizerThreadWorker+bb 
clr!Frame::Push+59 
clr!PEDecoder::GetNativeCodeManagerTable+170 
clr!PEDecoder::GetNativeCodeManagerTable+99 
[[DebuggerU2MCatchHandlerFrame]] 
clr!FinalizerThread::FinalizerThreadStart+10a 
clr!Thread::intermediateThreadProc+86 
kernel32!BaseThreadInitThunk+14 
ntdll!RtlUserThreadStart+21 
Closed Apr 30 at 7:23 PM by ClearScript

comments

ClearScript wrote Mar 20 at 1:26 AM

Hello!

Some questions:
  1. Can you describe your recycling configuration? For example, how is recycling triggered?
  2. Does the hang happen every time, or is it intermittent?
  3. As you may have noticed, some of the top stack frames above are missing or bogus, making diagnosis difficult if not impossible. Would you be able to deploy the relevant ClearScript and V8 PDB files for a cleaner stack? You might be able to get them from the owner of this NuGet project. Another possibility might be to generate all the files yourself by building ClearScript locally. The build procedure is outlined in the ClearScript ReadMe.
Thanks!

wolfeno wrote Mar 20 at 12:18 PM

Hi,
  1. Recycle is triggered by configuration file change
  2. Hang is intermittent
  3. I will try to get debug symbols for additional info

wolfeno wrote Apr 11 at 6:55 PM

Hi,

Sorry for delay.
Stack with symbols loaded for locally built version:
 # Child-SP          RetAddr           Call Site
00 000000eb`4437ed78 00007ffa`f9c4988f ntdll!ZwWaitForSingleObject+0x14
01 000000eb`4437ed80 00007ffa`bb02554c KERNELBASE!WaitForSingleObjectEx+0x9f
02 (Inline Function) --------`-------- v8_x64!v8::internal::MemoryAllocator::Unmapper::WaitUntilCompleted+0x16 [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\spaces.cc @ 366] 
03 000000eb`4437ee20 00007ffa`bad9e237 v8_x64!v8::internal::MemoryAllocator::TearDown+0x3c [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\spaces.cc @ 314] 
04 000000eb`4437ee60 00007ffa`bad76283 v8_x64!v8::internal::Heap::TearDown+0x477 [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\heap.cc @ 5591] 
05 000000eb`4437eea0 00007ffa`bad7b41b v8_x64!v8::internal::Isolate::Deinit+0x193 [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\isolate.cc @ 2150] 
06 000000eb`4437eed0 00007ffa`d0074216 v8_x64!v8::internal::Isolate::TearDown+0x5b [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\isolate.cc @ 2077] 
07 000000eb`4437ef10 00007ffa`d00720e4 ClearScriptV8_64!V8IsolateImpl::~V8IsolateImpl+0x286 [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp @ 656] 
08 000000eb`4437eff0 00007ffa`d0073e3f ClearScriptV8_64!V8IsolateImpl::`scalar deleting destructor'+0x14
09 (Inline Function) --------`-------- ClearScriptV8_64!SharedPtrTraits<V8IsolateImpl>::Destroy+0xe [c:\git\clearscript\clearscript\v8\clearscriptv8\sharedptr.h @ 143] 
0a (Inline Function) --------`-------- ClearScriptV8_64!SharedPtr<V8IsolateImpl>::Release+0x23 [c:\git\clearscript\clearscript\v8\clearscriptv8\sharedptr.h @ 338] 
0b (Inline Function) --------`-------- ClearScriptV8_64!SharedPtr<V8IsolateImpl>::{dtor}+0x23 [c:\git\clearscript\clearscript\v8\clearscriptv8\sharedptr.h @ 259] 
0c 000000eb`4437f020 00007ffa`d00650a8 ClearScriptV8_64!V8IsolateImpl::CallWithLockNoWait+0x1df [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp @ 628] 
0d 000000eb`4437f0d0 00007ffa`84f451fb ClearScriptV8_64!V8ContextImpl::Destroy+0x68 [c:\git\clearscript\clearscript\v8\clearscriptv8\v8contextimpl.cpp @ 530] 
0e 000000eb`4437f160 00007ffa`84f7121e 0x00007ffa`84f451fb
0f 000000eb`4437f210 00007ffa`84f47d1e 0x00007ffa`84f7121e
10 000000eb`4437f2c0 00007ffa`df5666c6 0x00007ffa`84f47d1e
11 000000eb`4437f300 00007ffa`df71a741 clr!LogHelp_LogAssert+0x1b46
12 000000eb`4437f330 00007ffa`df71a6c9 clr!MetaDataGetDispenser+0x3ff11
13 000000eb`4437f380 00007ffa`df71a602 clr!MetaDataGetDispenser+0x3fe99
14 000000eb`4437f3d0 00007ffa`df71a4b9 clr!MetaDataGetDispenser+0x3fdd2
15 000000eb`4437f410 00007ffa`df71a3cc clr!MetaDataGetDispenser+0x3fc89
16 000000eb`4437f4f0 00007ffa`df71bc87 clr!MetaDataGetDispenser+0x3fb9c
17 000000eb`4437f540 00007ffa`df567c9d clr!MetaDataGetDispenser+0x41457
18 000000eb`4437f570 00007ffa`df567c18 clr!LogHelp_LogAssert+0x311d
19 000000eb`4437f5b0 00007ffa`df567b56 clr!LogHelp_LogAssert+0x3098
1a 000000eb`4437f6b0 00007ffa`df56a864 clr!LogHelp_LogAssert+0x2fd6
1b 000000eb`4437f740 00007ffa`df5b2fe9 clr!LogHelp_LogAssert+0x5ce4
1c 000000eb`4437f770 00007ffa`df56a845 clr!LogHelp_NoGuiOnAssert+0x46dd9
1d 000000eb`4437f920 00007ffa`df71bc33 clr!LogHelp_LogAssert+0x5cc5
1e 000000eb`4437f960 00007ffa`df71a3cc clr!MetaDataGetDispenser+0x41403
1f 000000eb`4437fa40 00007ffa`df71977b clr!MetaDataGetDispenser+0x3fb9c
20 000000eb`4437fa90 00007ffa`df567c9d clr!MetaDataGetDispenser+0x3ef4b
21 000000eb`4437fad0 00007ffa`df567c18 clr!LogHelp_LogAssert+0x311d
22 000000eb`4437fb10 00007ffa`df567b56 clr!LogHelp_LogAssert+0x3098
23 000000eb`4437fc10 00007ffa`df69f87a clr!LogHelp_LogAssert+0x2fd6
24 000000eb`4437fca0 00007ffa`df6631cf clr!PreBindAssemblyEx+0x11aa
25 000000eb`4437fd40 00007ffa`fa102774 clr!GetPrivateContextsPerfCounters+0x10b6f
26 000000eb`4437fe00 00007ffa`fcc00d61 kernel32!BaseThreadInitThunk+0x14
27 000000eb`4437fe30 00000000`00000000 ntdll!RtlUserThreadStart+0x21

ClearScript wrote Apr 11 at 7:29 PM

Hi again,

Thanks for the stack. Which ClearScript version did you build locally?

Thanks!

wolfeno wrote Apr 11 at 7:34 PM

I've checked out tag 5.4.8.
Here is a stack with SOSex loaded
Current frame: ntdll!NtWaitForSingleObject+0x14
Child-SP         RetAddr          Caller, Callee
000000eb4437ed70 00007ffaf9c4988f KERNELBASE!WaitForSingleObjectEx+0x9f, calling ntdll!NtWaitForSingleObject
000000eb4437ed90 00007ffaf9ffc97b ucrtbase!free_base+0x1b, calling ntdll!RtlFreeHeap
000000eb4437edf0 00007ffaf9ffc97b ucrtbase!free_base+0x1b, calling ntdll!RtlFreeHeap
000000eb4437ee10 00007ffabb02554c v8_x64!v8::internal::MemoryAllocator::TearDown+0x3c [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\spaces.cc:314], calling v8_x64!v8::base::Semaphore::Wait [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\base\platform\semaphore.cc:158]
000000eb4437ee20 00007ffabae099eb v8_x64!v8::internal::StoreBuffer::TearDown+0x2b [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\store-buffer.cc:56], calling v8_x64!operator delete [f:\dd\vctools\crt\vcstartup\src\heap\delete_scalar_size.cpp:14]
000000eb4437ee50 00007ffabad9e237 v8_x64!v8::internal::Heap::TearDown+0x477 [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\heap.cc:5591], calling v8_x64!v8::internal::MemoryAllocator::TearDown [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\spaces.cc:313]
000000eb4437ee90 00007ffabad76283 v8_x64!v8::internal::Isolate::Deinit+0x193 [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\isolate.cc:2150], calling v8_x64!v8::internal::Heap::TearDown [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\heap\heap.cc:5474]
000000eb4437eec0 00007ffabad7b41b v8_x64!v8::internal::Isolate::TearDown+0x5b [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\isolate.cc:2077], calling v8_x64!v8::internal::Isolate::Deinit [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\isolate.cc:2102]
000000eb4437ef00 00007ffad0074216 ClearScriptV8_64!V8IsolateImpl::~V8IsolateImpl+0x286 [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp:656], calling v8_x64!v8::Isolate::Dispose [c:\git\clearscript\clearscript\v8\v8\build\v8-x64\src\api.cc:7473]
000000eb4437efb0 00007ffacf26886f msvcp140!__crtReleaseSRWLockExclusive+0x23 [f:\dd\vctools\crt\crtw32\misc\winapisupp.cpp:612], calling msvcp140!_guard_check_icall [f:\dd\vctools\crt\vcstartup\src\misc\checkcfg.c:61]
000000eb4437efe0 00007ffad00720e4 ClearScriptV8_64!V8IsolateImpl::`scalar deleting destructor'+0x14, calling ClearScriptV8_64!V8IsolateImpl::~V8IsolateImpl [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp:641]
000000eb4437f010 00007ffad0073e3f ClearScriptV8_64!V8IsolateImpl::CallWithLockNoWait+0x1df [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp:628]
000000eb4437f040 00007ffadf56d7ef clr!PreStubWorker+0x2e0, calling kernel32!SetLastErrorStub
000000eb4437f0c0 00007ffad00650a8 ClearScriptV8_64!V8ContextImpl::Destroy+0x68 [c:\git\clearscript\clearscript\v8\clearscriptv8\v8contextimpl.cpp:530], calling ClearScriptV8_64!V8IsolateImpl::CallWithLockNoWait [c:\git\clearscript\clearscript\v8\clearscriptv8\v8isolateimpl.cpp:613]
000000eb4437f150 00007ffa84f451fb (MethodDesc 00007ffa8518d600 +0xcb <Module>.SharedPtr<V8Context>.Release(SharedPtr<V8Context>*))
000000eb4437f1b0 00007ffa84f451fb (MethodDesc 00007ffa8518d600 +0xcb <Module>.SharedPtr<V8Context>.Release(SharedPtr<V8Context>*))
000000eb4437f200 00007ffa84f7121e (MethodDesc 00007ffa851c0a38 +0x4e Microsoft.ClearScript.V8.V8ContextProxyImpl.!V8ContextProxyImpl()), calling (MethodDesc 00007ffa8518d600 +0 <Module>.SharedPtr<V8Context>.Release(SharedPtr<V8Context>*))
000000eb4437f2b0 00007ffa84f47d1e (MethodDesc 00007ffa851c0a78 +0x1e Microsoft.ClearScript.V8.V8ContextProxyImpl.Dispose(Boolean)), calling 00007ffa84f41aa8 (stub for Microsoft.ClearScript.V8.V8ContextProxyImpl.!V8ContextProxyImpl())
000000eb4437f2f0 00007ffadf5666c6 clr!FastCallFinalizeWorker+0x6
000000eb4437f320 00007ffadf71a741 clr!ETW::GCLog::SendFinalizeObjectEvent+0xc9, calling clr!FastCallFinalizeWorker
000000eb4437f340 00007ffadf728650 clr!MethodTable::IsInitError+0x1d, calling clr!DomainLocalModule::GetClassFlags
000000eb4437f370 00007ffadf71a6c9 clr!MethodTable::CallFinalizer+0xb5, calling clr!ETW::GCLog::SendFinalizeObjectEvent+0x74
000000eb4437f3a0 00007ffadf566649 clr!CallDescrWorkerWithHandler+0x4e, calling clr!CallDescrWorkerInternal
000000eb4437f3c0 00007ffadf71a602 clr!CallFinalizer+0x5e, calling clr!MethodTable::CallFinalizer
000000eb4437f3d0 00007ffaf9c3a8d4 KERNELBASE!SetThreadLocale+0x14, calling KERNELBASE!NlsValidateLocale
000000eb4437f400 00007ffadf71a4b9 clr!FinalizerThread::DoOneFinalization+0x95, calling clr!CallFinalizer
000000eb4437f480 00007ffadf72d4ed clr!DistributeEventReliably+0x269, calling clr!_security_check_cookie
000000eb4437f4a0 00007ffadf719ce0 clr!SVR::GCHeap::GetNextFinalizableObject+0x5c, calling clr!SVR::CFinalize::IsSegEmpty
000000eb4437f4e0 00007ffadf71a3cc clr!FinalizerThread::FinalizeAllObjects+0x124, calling clr!FinalizerThread::DoOneFinalization
000000eb4437f530 00007ffadf71bc87 clr!FinalizerThread::FinalizeAllObjects_Wrapper+0x18, calling clr!FinalizerThread::FinalizeAllObjects
000000eb4437f560 00007ffadf567c9d clr!Frame::Push+0x59
000000eb4437f5a0 00007ffadf567c18 clr!MarshalInfo::SetupArgumentSizes+0x234, calling clr!Frame::Push+0x20
000000eb4437f5b0 00007ffadf72d349 clr!DistributeEventReliably+0xa9, calling clr!CLRException::HandlerState::CleanupTry
000000eb4437f600 00007ffadf56a114 clr!Thread::SetLastThrownObject+0x35, calling clr!StressLog::LogOn
000000eb4437f670 00007ffadf56737d clr!FrameWithCookie<DebuggerU2MCatchHandlerFrame>::FrameWithCookie<DebuggerU2MCatchHandlerFrame>+0x26, calling clr!Frame::Push
000000eb4437f690 00007ffadf56718c clr!SystemDomain::GetAppDomainAtId+0x40, calling clr!AppDomain::CanThreadEnter
000000eb4437f6a0 00007ffadf567b56 clr!MarshalInfo::SetupArgumentSizes+0x15d, calling clr!MarshalInfo::SetupArgumentSizes+0x1c8
000000eb4437f6b0 00007ffadf85c7b5 clr!AppDomain::RaiseUnloadDomainEvent+0x71, calling clr!CLRException::HandlerState::CleanupTry
000000eb4437f6c0 00007ffadf566051 clr!ClrFlsIncrementValue+0x29
000000eb4437f730 00007ffadf56a864 clr!Thread::ShouldChangeAbortToUnload+0x45, calling clr!MarshalInfo::SetupArgumentSizes+0xe8
000000eb4437f760 00007ffadf5b2fe9 clr!Thread::DoADCallBack+0x109
000000eb4437f790 00007ffadf653857 clr!Thread::DoADCallBack+0x27a, calling clr!Thread::ReturnToContext
000000eb4437f840 00007ffafcbc0f30 ntdll!RtlFreeHeap+0x150, calling ntdll!RtlGetCurrentServiceSessionId
000000eb4437f850 00007ffadf565ff6 clr!CrstBase::Enter+0x6a, calling ntdll!RtlTryEnterCriticalSection
000000eb4437f910 00007ffadf56a845 clr!Frame::Push+0xa2, calling clr!Thread::DoADCallBack
000000eb4437f920 00007ffadf56af62 clr!FrameWithCookie<GCFrame>::FrameWithCookie<GCFrame>+0x42, calling clr!GetThread
000000eb4437f950 00007ffadf71bc33 clr!FinalizerThread::DoOneFinalization+0x1f2, calling clr!Frame::Push+0x20
000000eb4437f9f0 00007ffadf719ce0 clr!SVR::GCHeap::GetNextFinalizableObject+0x5c, calling clr!SVR::CFinalize::IsSegEmpty
000000eb4437fa30 00007ffadf71a3cc clr!FinalizerThread::FinalizeAllObjects+0x124, calling clr!FinalizerThread::DoOneFinalization
000000eb4437fa80 00007ffadf71977b clr!FinalizerThread::FinalizerThreadWorker+0xbb, calling clr!FinalizerThread::FinalizeAllObjects
000000eb4437fa88 00007ffadf85d700 clr!GetLogicalCpuCount+0x8a, calling clr!GetLogicalCpuCountFromOS
000000eb4437fac0 00007ffadf567c9d clr!Frame::Push+0x59
000000eb4437fb00 00007ffadf567c18 clr!MarshalInfo::SetupArgumentSizes+0x234, calling clr!Frame::Push+0x20
000000eb4437fbb0 00007ffadf69bbc2 clr!Wrapper<void * __ptr64,&DoNothing<void * __ptr64>,&VoidCloseHandle,-1,&CompareDefault<void * __ptr64>,2,1>::~Wrapper<void * __ptr64,&DoNothing<void * __ptr64>,&VoidCloseHandle,-1,&CompareDefault<void * __ptr64>,2,1>+0x30, calling kernel32!CloseHandle
000000eb4437fbd0 00007ffadf56737d clr!FrameWithCookie<DebuggerU2MCatchHandlerFrame>::FrameWithCookie<DebuggerU2MCatchHandlerFrame>+0x26, calling clr!Frame::Push
000000eb4437fbf0 00007ffadf6b9d96 clr!ProfilingAPIAttachDetach::CreateAttachThread+0x76, calling clr!Wrapper<void * __ptr64,&DoNothing<void * __ptr64>,&VoidCloseHandle,-1,&CompareDefault<void * __ptr64>,2,1>::~Wrapper<void * __ptr64,&DoNothing<void * __ptr64>,&VoidCloseHandle,-1,&CompareDefault<void * __ptr64>,2,1>
000000eb4437fc00 00007ffadf567b56 clr!MarshalInfo::SetupArgumentSizes+0x15d, calling clr!MarshalInfo::SetupArgumentSizes+0x1c8
000000eb4437fc10 00007ffadf6a87d3 clr!EEConfig::GetConfigDWORD_DontUse_+0x3b, calling clr!EEConfig::GetConfiguration_DontUse_
000000eb4437fc90 00007ffadf69f87a clr!FinalizerThread::FinalizerThreadStart+0x10a, calling clr!MarshalInfo::SetupArgumentSizes+0xe8
000000eb4437fcd0 00007ffadf566929 clr!EEHeapFreeInProcessHeap+0x45, calling kernel32!HeapFreeStub
000000eb4437fd30 00007ffadf6631cf clr!Thread::intermediateThreadProc+0x86
000000eb4437fdb0 00007ffadf6631af clr!Thread::intermediateThreadProc+0x66, calling clr!_chkstk
000000eb4437fdf0 00007ffafa102774 kernel32!BaseThreadInitThunk+0x14, calling ntdll!LdrpDispatchUserCallTarget
000000eb4437fe20 00007ffafcc00d61 ntdll!RtlUserThreadStart+0x21, calling ntdll!LdrpDispatchUserCallTarget

ClearScript wrote Apr 11 at 9:19 PM

Thanks again. A question: Does the hang block the recycling of the application pool indefinitely, or does the system eventually detect it and terminate the process?

wolfeno wrote Apr 11 at 9:37 PM

It seems indefinitely to me. Last time it was hanging for about an hour before I've killed w3wp process.

ClearScript wrote Apr 12 at 3:01 PM

Thanks! Last question (hopefully): Did you have to build anything else locally (e.g., JavaScriptEngineSwitcher, ReactJS.NET, etc.) in order to deploy your private version of ClearScript?

wolfeno wrote Apr 12 at 3:42 PM

Yes, I had to build JavaScriptEngineSwitcher locally to be able to use private version of ClearScript.

ClearScript wrote Apr 19 at 1:52 AM

We've posted a potential fix here. Since we haven't been able to reproduce the issue, it would be great if you could give it a try. As the fix is relative to ClearScript 5.4.9, you might pick up some performance improvements as well. Good luck, and thanks again!

wolfeno wrote Apr 19 at 9:42 AM

I'm no longer able to reproduce this deadlock.
It restarts successfully, but now crashes on start with automatic restart afterwards.
Crash is intermittent. Weren't able to repro with attached debugger.

Here is a stack trace
Exception: System.Reflection.TargetInvocationException

Message: Exception has been thrown by the target of an invocation.

StackTrace:    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.Web.Mvc.HtmlHelperExtensions.get_Environment()
   at React.Web.Mvc.HtmlHelperExtensions.React[T](HtmlHelper htmlHelper, String componentName, T props, String htmlTag, String containerId, Boolean clientOnly, Boolean serverOnly, String containerClass)


InnerException: System.AccessViolationException

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

StackTrace:    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)

ClearScript wrote Apr 19 at 1:48 PM

An access violation inside native V8 initialization nearly always indicates an out-of-memory condition. When it fails to allocate resources, V8 immediately crashes the process by raising an access violation.

At startup, a V8 runtime tries to acquire large amounts of memory and address space to be handed off to its internal resource manager. Any allocation failure leads to an immediate crash.

Does your crash always happen after a recycle? Or can it happen randomly at any time?

Other questions: Does your application run in a 32-bit process? Is it possible that it creates a large number of V8 runtimes? Does it specify memory limits via V8RuntimeConstraints?

wolfeno wrote Apr 19 at 3:38 PM

Today is the first time I observed this. I observed it only after recycle.
IIS is running in 64-bit mode.
V8RuntimeConstraints contain MaxNewSpaceSize = 0, MaxOldSpaceSize = 0, MaxExecutableSize = 0.

ClearScript wrote Apr 20 at 9:21 PM

Would it be possible to collect a full native call stack? Since you built V8 and ClearScript locally, you should have all the necessary symbols.

wolfeno wrote Apr 28 at 11:10 PM

Hi again,

I've updated to latest JavaScriptEngineSwitcher today which includes your fix and seems like I'm not able to reproduce any of the above issues anymore.
Thanks for your support!

ClearScript wrote Apr 30 at 7:23 PM

That's great to hear. Thank you very much!