asio icon indicating copy to clipboard operation
asio copied to clipboard

Unhandled exception 0xC0000008

Open xavier2k6 opened this issue 5 years ago • 5 comments

What is the problem

Unhandled exception 0xC0000008 for boost asio being caught while running qBittorrent program.

Steps to reproduce

EDIT: Enable Handle Checking in Application Verifier qBittorrent Application Verifier Settings

System

Windows 10 Pro x64 Version 1909 Build 18363.753 32GB Ram qBittorrent 4.2.2/4.2.3 Boost 1.72 (may have been occurring in previous versions)

Just started up qBittorrent program & was waiting for it to fully load up for a few minutes.

Will occur when program is running too.

Stack traces caught with Microsoft's Debug Diagagnostic Tool 2.3.0.37

(3894.a1c): Invalid handle - code c0000008 (first chance)
[3/31/2020 5:33:01 PM]
  Exception 0XC0000008 on thread 2588. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ffd`02c5158b : 00000000`00000614 000000ab`80fff1b0 000000ab`80fff1b8 000000ab`80fff1c0 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ffd`12a9ec88 : 00000000`00000000 00000000`00000624 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ffd`16181f7c : ffffffff`ffffffff 00000290`c9982e80 00000000`00000000 00000000`00000000 : MSWSOCK!WSPSelect+0x588
00007ff6`c6566e8e : 00000290`c99e7ff0 00000290`c9982f98 00000290`c9982e50 00000290`c9982e80 : WS2_32!select+0x1ac
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x85 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\socket_ops.ipp @ 1795]
00007ff6`c6567030 : 00000000`00000001 00000000`00000000 00000290`c70c3f50 00000000`00000a1c : qbittorrent!boost::asio::detail::select_reactor::run+0x2de [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
00007ff6`c6504a7e : 00000290`c99f5fd0 00000000`00000000 00000290`c99effe0 00007ff6`c6504a60 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x68 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 280]
00007ff6`c6fdf850 : 00000290`c99effe0 00000290`c99f5fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ffd`02c52534 : 00000290`b8ab9fc0 00000000`00000000 00000290`b8ab9fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ffd`157a7bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007ffd`1642ced1 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x14
00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21
  Action limit of 1 reached for Exception 'C0000008::'.
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.


=======================================
VERIFIER STOP 0000000000000300: pid 0x3894: Invalid handle exception for current stack trace. 

	00000000C0000008 : Exception code.
	000000AB80FFEE70 : Exception record. Use .exr to display it.
	000000AB80FFE980 : Context record. Use .cxr to display it.
	0000000000000000 : Not used.


=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.

=======================================
(3894.a1c): Break instruction exception - code 80000003 (first chance)
  Exception 0X80000003 on thread 2588. DetailID = 2
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ffd`02c42a19 : 000000ab`80ffe710 00000290`b48308b0 00000000`00000002 00007ffd`16407cfd : vrfcore!VerifierStopMessageEx+0x7dc
00007ffd`16438636 : 00007ffd`02c42990 000000ab`80ffe700 00000290`b48308b0 00000000`00000000 : vfbasics+0x2a19
00007ffd`1642a0d6 : 000000ab`80ffee70 000000ab`80ffe980 00000000`00000000 00000000`00000001 : ntdll!RtlpCallVectoredHandlers+0x196
00007ffd`1645fe8e : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlDispatchException+0x66
00007ffd`1645ff0a : 00000290`b60a0000 00000000`00000000 00000291`8d006ef0 00000000`00000110 : ntdll!KiUserExceptionDispatch+0x2e
00007ffd`02c5158b : 00000000`00000614 000000ab`80fff1b0 000000ab`80fff1b8 000000ab`80fff1c0 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ffd`12a9ec88 : 00000000`00000000 00000000`00000624 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ffd`16181f7c : ffffffff`ffffffff 00000290`c9982e80 00000000`00000000 00000000`00000000 : MSWSOCK!WSPSelect+0x588
00007ff6`c6566e8e : 00000290`c99e7ff0 00000290`c9982f98 00000290`c9982e50 00000290`c9982e80 : WS2_32!select+0x1ac
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x85 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\socket_ops.ipp @ 1795]
00007ff6`c6567030 : 00000000`00000001 00000000`00000000 00000290`c70c3f50 00000000`00000a1c : qbittorrent!boost::asio::detail::select_reactor::run+0x2de [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
00007ff6`c6504a7e : 00000290`c99f5fd0 00000000`00000000 00000290`c99effe0 00007ff6`c6504a60 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x68 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 280]
00007ff6`c6fdf850 : 00000290`c99effe0 00000290`c99f5fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ffd`02c52534 : 00000290`b8ab9fc0 00000000`00000000 00000290`b8ab9fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ffd`157a7bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007ffd`1642ced1 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : KERNEL32!BaseThreadInitThunk+0x14
00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x21
  Action limit of 1 reached for unconfigured first chance exceptions.
[3/31/2020 5:33:54 PM]

related qBittorrent thread on their issue tracker #12329

another user on their issue tracker experienced same or similar #12413

Log with 65 Hits of 0xC0000008 qbittorrent__PID__5832__Date__04_02_2020__Time_01_29_25AM__167__Log.txt

xavier2k6 avatar Apr 04 '20 21:04 xavier2k6

Just wonder, might be useful, have you tried to change the calls stack? - eg. instead process supposedly in an lambda, change to a [&ptr](){ptr->your_process()}; so the called process is within your stack trace and so as if the exception happened within the process , it is not the one handled by asio.

kashirin-alex avatar Apr 04 '20 22:04 kashirin-alex

C0000008 is STATUS_INVALID_HANDLE - this is likely an bad SOCKET being given to select() [either null or a SOCKET that was already closed].

keith-horton avatar Jun 25 '20 03:06 keith-horton

Any update on this?

mateialexandru avatar May 01 '21 00:05 mateialexandru

Any update on this?

Still happens. https://github.com/qbittorrent/qBittorrent/issues/12329#issuecomment-1100782226

rugabunda avatar Apr 17 '22 01:04 rugabunda

Exception is still occurring in v4.4.2; if you cant use appverifier, it can be simply tested by enabling "validate handle usage" for qbittorrent.exe in windows exploit protection settings. It happens far more frequently if you have many torrents in seeding mode. The exception used to cause qbit to crash every so many hours, now happens for me within 20-30 seconds after force enabling more seeds. This is without re-checking files and all torrents already downloaded. Looks like it has to do with sending invalid handles to winsock;

rugabunda avatar Apr 17 '22 01:04 rugabunda

Is this still an issue?

luzpaz avatar May 29 '23 22:05 luzpaz

bumping for visibility

luzpaz avatar Jul 19 '23 20:07 luzpaz

If you enable the Handles check in AppVerifier, then you can look at the !avrf output in the debugger, which will give you a pointer of the stack that opened and later closed the handle - which you can run 'dps

' to have the debugger print out the stack when it was closed.

keith-horton avatar Jul 19 '23 20:07 keith-horton