Occasional hangs in the runtime

2020
2
05-25-2016 10:33 AM
carloscasanova
New Contributor III

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

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

Reply
0 Kudos
2 Replies
carloscasanova
New Contributor III

another (abbreviated) main stack. This one is not blocked on a join.

00000000`004ac948 000007fe`fcee10ac : 00000000`3de0efb0 ffffffff`fffffffe 00000000`26b899c0 00000000`3cb2b680 : ntdll!ZwWaitForSingleObject+0xa

00000000`004ac950 000007fe`d79fc07b : 00000000`1fea8ef0 00000000`00000000 00000000`00000000 00000000`0000085c : KERNELBASE!WaitForSingleObjectEx+0x79

00000000`004ac9f0 000007fe`d79f94de : 00000000`1fea8ef0 000007fe`f14ecfb4 00000000`254217e0 00000000`00000000 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::find+0x7e55b

00000000`004aca40 000007fe`d7a4d510 : 00000000`004acaa0 00000000`00000000 00000000`00000000 00000000`00000000 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::find+0x7b9be

00000000`004aca80 000007fe`d7a4b650 : 00000000`1ff1d220 00000000`004acbd8 00000000`25421750 00000000`1ff1d210 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::erase+0x1a920

00000000`004acb50 000007fe`d7a6ba6f : 00000000`25421750 00000000`23b11260 00000000`25421750 00000000`00000000 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::erase+0x18a60

00000000`004acba0 000007fe`d798d0c9 : 00000000`004ad530 00000000`27611450 00000000`23b11260 000007fe`d8ba2288 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::erase+0x38e7f

00000000`004acc20 000007fe`d7985213 : 00000000`27bb09a8 00000000`27bb09a8 00000000`27bb09a8 00000000`23b11260 : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::find+0xf5a9

00000000`004acc50 000007fe`d77bea63 : 000007fe`ebe6fc80 000007fe`8c7693a0 00000000`25786310 ffffffff`fffffffe : RuntimeCoreNETDesktop!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::find+0x76f3

00000000`004accd0 000007fe`8c955a6c : 000007fe`8c768470 00000000`25786310 00000000`0061b530 00000000`25786310 : RuntimeCoreNETDesktop!MapRemoveLayerAt+0xd3

Reply
0 Kudos
carloscasanova
New Contributor III
Reply
0 Kudos