nunit hangs in finalize

Bug reports.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

nunit hangs in finalize

Post by jabelshauser » Thu Jul 10, 2014 12:34 pm

Seems to be caused by this thread (GC Finalizer Thread)

> mscorlib.dll!System.GC.SuppressFinalize(object obj) + 0x11 bytes
Ranorex.Libs.WinForms.dll!Ranorex.Libs.WinForms.MarshalByRefControlProxy.~MarshalByRefControlProxy() + 0x52 bytes
Ranorex.Libs.WinForms.dll!Ranorex.Libs.WinForms.MarshalByRefControlProxy.Dispose(bool ) + 0x1a bytes
Ranorex.Libs.WinForms.dll!Ranorex.Libs.WinForms.MarshalByRefControlProxy.Dispose() + 0x15 bytes
Ranorex.Plugin.WinForms.dll!Ranorex.Plugin.WinFormsFlavorElement.Finalize() + 0x27 bytes

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: nunit hangs in finalize

Post by Support Team » Tue Jul 15, 2014 12:53 pm

Hi,

May I ask you which Ranorex and NUnit version you are using and
if the application under test gets closed before the finalize is executed?

Regards,
Markus
.
Image

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Re: nunit hangs in finalize

Post by jabelshauser » Tue Jul 15, 2014 1:44 pm

Ranorex Version: 5.0.2
NUnit Version: 2.6.1

The SUT is closed before the finalize is executed.

Occurs, if Test executed with the timeout-attribute + RequireSTA.
Occurs Not, if Test executed without timeout-attribute but RequireSTA.

Behaviour with Ranorex 5.1:
Finalizer Thread:
> [email protected]()
[email protected]() + 0xc bytes
[email protected]() + 0x8b bytes
[email protected]() + 0x12 bytes
ole32.dll!GetToSTA() + 0x4e bytes
ole32.dll!CRpcChannelBuffer::SwitchAptAndDispatchCall() + 0xcde bytes
ole32.dll!CRpcChannelBuffer::SendReceive2() + 0x82 bytes
ole32.dll!CAptRpcChnl::SendReceive() + 0x46 bytes
ole32.dll!CCtxComChnl::SendReceive() - 0x6f83 bytes
[email protected]() + 0x40 bytes
rpcrt4.dll!_NdrClientCall2() + 0x9dd bytes
[email protected]() + 0x5d bytes
[email protected]() + 0xf bytes
ole32.dll!CObjectContext::InternalContextCallback() - 0x30ee bytes
ole32.dll!CObjectContext::ContextCallback() + 0x85 bytes
mscorwks.dll!CtxEntry::EnterContextOle32BugAware() + 0x2b bytes
mscorwks.dll!CtxEntry::EnterContext() + 0x168 bytes
mscorwks.dll!RCWCleanupList::ReleaseRCWListInCorrectCtx() + 0xf7 bytes
mscorwks.dll!RCWCleanupList::CleanupAllWrappers() + 0xcfa24 bytes
mscorwks.dll!SyncBlockCache::CleanupSyncBlocks() + 0xdb bytes
mscorwks.dll!Thread::DoExtraWorkForFinalizer() + 0xd6d67 bytes
mscorwks.dll!WKS::GCHeap::FinalizerThreadWorker() + 0x89 bytes
mscorwks.dll!Thread::DoADCallBack() - 0x4d7b3 bytes
mscorwks.dll!Thread::ShouldChangeAbortToUnload() - 0x4c92b bytes
mscorwks.dll!Thread::ShouldChangeAbortToUnload() - 0x4ca05 bytes
mscorwks.dll!ManagedThreadBase_NoADTransition() + 0x32 bytes
mscorwks.dll!ManagedThreadBase::FinalizerBase() + 0xd bytes
mscorwks.dll!WKS::GCHeap::FinalizerThreadStart() + 0xa9 bytes
mscorwks.dll!Thread::intermediateThreadProc() + 0x46 bytes
[email protected]() + 0x37 bytes

Test execution thread:
> [email protected]()
[email protected]() + 0xc bytes
[email protected]() - 0x48 bytes
[email protected]() + 0xd9 bytes
ole32.dll!CCliModalLoop::BlockFn() + 0x76 bytes
[email protected]() + 0xe6 bytes
mscorwks.dll!NT5WaitRoutine() + 0x39 bytes
mscorwks.dll!MsgWaitHelper() + 0x97 bytes
mscorwks.dll!Thread::DoAppropriateAptStateWait() + 0x674a0 bytes
mscorwks.dll!Thread::DoAppropriateWaitWorker() + 0x104 bytes
mscorwks.dll!Thread::DoAppropriateWait() + 0x40 bytes
mscorwks.dll!CLREvent::WaitEx() + 0xf3f3d bytes
mscorwks.dll!CLREvent::Wait() + 0x17 bytes
mscorwks.dll!WKS::GCHeap::FinalizerThreadWait() + 0xec bytes
mscorwks.dll!ReleaseRCWsInCaches() + 0x109e71 bytes
mscorwks.dll!ReleaseRCWsInCachesNoThrow() + 0x67 bytes
mscorwks.dll!Thread::CleanupCOMState() + 0x21d585 bytes
mscorwks.dll!Thread::OnThreadTerminate() + 0x46 bytes
mscorwks.dll!DestroyThread() + 0x3b bytes
mscorwks.dll!ThreadNative::KickOffThread() + 0xf2 bytes
mscorwks.dll!Thread::intermediateThreadProc() + 0x46 bytes
[email protected]() + 0x37 bytes

Regards,
Jörg

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: nunit hangs in finalize

Post by Support Team » Thu Jul 17, 2014 2:31 pm

Hi Jörg,

Do you test a WinForms application?

You are getting this error message when the timeout is reached and the NUnit test runner therefore aborts the test execution, right?
Does it also happen when the test stops in the normal way, so within the timeout period?
In general every thread which executes and access Ranorex code must be set to STA (Single Threaded Apartment) COM model.
I am unfortunately not totally sure how the NUnit Timeout internally works but it seems that this is somehow done in a separate thread and that this seems to break the execution.
It is possible for you to use another approach than using the timeout attribute?

Regards,
Markus
.
Image