AnsweredAssumed Answered

Occasional hangs in the runtime

Question asked by ccasanova on May 25, 2016
Latest reply on Jun 1, 2016 by ccasanova

I've been debugging some sporadic hangs. I found one problem (which may lead to others!)

A thread join is executed on the main thread. Unfortunately, this means an infinite wait. The join implementation looks something like this:

 

int _Thrd_join(_Thrd_t thr, int *code)

  { /* return exit code when thread terminates */

  unsigned long res;

  if (WaitForSingleObjectEx(thr._Hnd, INFINITE, FALSE) == WAIT_FAILED

    || GetExitCodeThread(thr._Hnd, &res) == 0)

    return (_Thrd_error);

  if (code)

    *code = (int)res;

  return (CloseHandle(thr._Hnd) == 0 ? _Thrd_error : _Thrd_success);

  }

 

Note the WaitForSingleObjectEx with an INFINITE timeout. 

 

Callstack for main thread:

 

00000000`0052dd68 000007fe`fd4310ac ntdll!ZwWaitForSingleObject+0xa

00000000`0052dd70 000007fe`e680cb34 KERNELBASE!WaitForSingleObjectEx+0x79

00000000`0052de10 000007fe`e69716e1 msvcp120!_Thrd_join+0x1c [f:\dd\vctools\crt\crtw32\stdcpp\thr\cthread.c @ 71]

00000000`0052de40 000007fe`e6971093 RuntimeCoreNETDesktop!UnitEquals+0x1091

00000000`0052de90 000007fe`e6971e48 RuntimeCoreNETDesktop!UnitEquals+0xa43

00000000`0052ded0 000007fe`8f197ab7 RuntimeCoreNETDesktop!DrawSurfaceShutdownDrawThread+0xc8

00000000`0052df40 000007fe`8f48a515 0x000007fe`8f197ab7

00000000`0052dff0 000007fe`8f35c997 0x000007fe`8f48a515

00000000`0052e020 000007fe`8f35cb48 0x000007fe`8f35c997

00000000`0052e050 000007fe`eb7112d0 0x000007fe`8f35cb48

00000000`0052e090 000007fe`eb6f54f6 PresentationCore_ni!`string'+0x14ef08

00000000`0052e140 000007fe`ea3c8058 PresentationCore_ni!`string'+0x13312e

00000000`0052e1a0 000007fe`ea2f13b1 PresentationFramework_ni+0x538058

00000000`0052e230 000007fe`eb728e26 PresentationFramework_ni+0x4613b1

00000000`0052e290 000007fe`eb70dca5 PresentationCore_ni!`string'+0x166a5e

00000000`0052e2c0 000007fe`eb70dbb1 PresentationCore_ni!`string'+0x14b8dd

00000000`0052e300 000007fe`eb70d93c PresentationCore_ni!`string'+0x14b7e9

00000000`0052e350 000007fe`eb70d822 PresentationCore_ni!`string'+0x14b574

00000000`0052e3c0 000007fe`ef2d1769 PresentationCore_ni!`string'+0x14b45a

00000000`0052e410 000007fe`ef2d1666 WindowsBase_ni+0x121769

00000000`0052e480 000007fe`ef2d463b WindowsBase_ni+0x121666

00000000`0052e4d0 000007fe`ed30ad2e WindowsBase_ni+0x12463b

00000000`0052e550 000007fe`ed30abc7 mscorlib_ni+0x52ad2e

00000000`0052e620 000007fe`ed30ab82 mscorlib_ni+0x52abc7

00000000`0052e650 000007fe`ef2d439e mscorlib_ni+0x52ab82

00000000`0052e6a0 000007fe`ef2cf762 WindowsBase_ni+0x12439e

00000000`0052e710 000007fe`ef2cfba1 WindowsBase_ni+0x11f762

00000000`0052e790 000007fe`ef2d19f3 WindowsBase_ni+0x11fba1

00000000`0052e810 000007fe`ef2d1922 WindowsBase_ni+0x1219f3

00000000`0052e8a0 000007fe`ef2d1769 WindowsBase_ni+0x121922

00000000`0052e8f0 000007fe`ef2d1666 WindowsBase_ni+0x121769

00000000`0052e960 000007fe`ef2cf0d1 WindowsBase_ni+0x121666

00000000`0052e9b0 000007fe`ef2d108f WindowsBase_ni+0x11f0d1

00000000`0052ea50 000007fe`ef49202a WindowsBase_ni+0x12108f

00000000`0052eb00 000007fe`ee2d0b4e WindowsBase_ni+0x2e202a

00000000`0052eb70 00000000`77439c11 clr!UMThunkStub+0x6e

00000000`0052ec00 00000000`7743992a user32!UserCallWinProcCheckWow+0x1ad

00000000`0052ecc0 000007fe`ef300518 user32!DispatchMessageWorker+0x3d0

00000000`0052ed50 000007fe`ef2e555c WindowsBase_ni+0x150518

00000000`0052ee10 000007fe`ea255ad3 WindowsBase_ni+0x13555c

00000000`0052eea0 000007fe`ea2558bd PresentationFramework_ni+0x3c5ad3

00000000`0052eee0 000007fe`8ec504e8 PresentationFramework_ni+0x3c58bd

00000000`0052ef40 000007fe`ee2b3883 0x000007fe`8ec504e8

00000000`0052ef90 000007fe`ee2b3745 clr!CallDescrWorkerInternal+0x83

00000000`0052efd0 000007fe`ee2b3cf6 clr!CallDescrWorkerWithHandler+0x4e

00000000`0052f010 000007fe`ee3cedc8 clr!MethodDescCallSite::CallTargetWorker+0xf8

00000000`0052f110 000007fe`ee3cef6a clr!RunMain+0x1e7

00000000`0052f2f0 000007fe`ee3cee58 clr!Assembly::ExecuteMainMethod+0xb6

00000000`0052f5e0 000007fe`ee3cf000 clr!SystemDomain::ExecuteMainMethod+0x5ea

00000000`0052fc10 000007fe`ee3cf0c6 clr!ExecuteEXE+0x3f

00000000`0052fc80 000007fe`ee3e12d0 clr!CorExeMainInternal+0xb2

00000000`0052fd10 000007fe`f0008389 clr!CorExeMain+0x14

00000000`0052fd50 000007fe`f00a5b21 mscoreei!CorExeMain+0xe0

00000000`0052fda0 00000000`773159ed mscoree!CorExeMain_Exported+0x57

00000000`0052fdd0 00000000`7754b371 kernel32!BaseThreadInitThunk+0xd

00000000`0052fe00 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

Outcomes