Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Handle exception 0xC0000008 with 4.2.2 #12329

Open
xavier2k6 opened this issue Mar 30, 2020 · 38 comments
Open

Invalid Handle exception 0xC0000008 with 4.2.2 #12329

xavier2k6 opened this issue Mar 30, 2020 · 38 comments
Labels
Crash OS: Windows Issues specific to Windows

Comments

@xavier2k6
Copy link
Member

xavier2k6 commented Mar 30, 2020

Please provide the following information

qBittorrent version and Operating System

qBittorrent 4.2.2 (Official) - Windows 10 Pro x64 Version 1909 Build 18363.752

10.0.18363

If on linux, libtorrent-rasterbar and Qt version

N/A

What is the problem

Unhandled exception 0xC0000008

What is the expected behavior

Not to have a Unhandled exception 0xC0000008

Steps to reproduce

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

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

All torrents were in paused state before opening the program - so no download/uploading/seeding/checking etc.

See partial stacktrace below - boost asio problem?!

Extra info(if any)

(17b4.a80): Invalid handle - code c0000008 (first chance)
[3/30/2020 1:35:42 AM]
  Exception 0XC0000008 on thread 2756. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ffd`03f8158b : 00000000`000007d8 00000018`f69ff450 00000018`f69ff458 00000018`f69ff460 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ffd`12a9ec88 : 00000000`00000000 00000000`000007e8 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ffd`16181f7c : 00000018`f69ff778 00000018`f69ff778 00007ffd`03fb6ec0 00007ffd`03f74cf2 : MSWSOCK!WSPSelect+0x588
00007ff6`c6566e8e : 000001ff`6206dff0 000001ff`61f35f98 000001ff`61f35e50 000001ff`61f35e80 : 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 000001ff`5f465f50 00000000`00000a80 : qbittorrent!boost::asio::detail::select_reactor::run+0x2de [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
00007ff6`c6504a7e : 000001ff`62085fd0 00000000`00000000 000001ff`6207bfe0 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 : 000001ff`6207bfe0 000001ff`62085fd0 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`03f82534 : 000001ff`50dc7fc0 00000000`00000000 000001ff`50dc7fc0 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
[3/30/2020 1:35:43 AM]
  Action limit of 1 reached for unconfigured first chance exceptions.
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.


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

	00000000C0000008 : Exception code.
	00000018F69FF0F0 : Exception record. Use .exr to display it.
	00000018F69FEC00 : Context record. Use .cxr to display it.
	0000000000000000 : Not used.


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

=======================================

(17b4.a80): Break instruction exception - code 80000003 (first chance)
  Exception 0X80000003 on thread 2756. DetailID = 2
[3/30/2020 1:36:41 AM]

It did not crash per se, in fact the same instance of qBittorrent is currently running, have debugdiag attached as always & have added 0xC0000008 to my rules now for hopefully a full stacktrace if it happens again.

@xavier2k6
Copy link
Member Author

Kept logging them throughout the night while having about 5 torrents active, Have stopped qBittorrent running now & going to restart to see if it happens again.......

***********************
*  EXCEPTION DETAILS  *
***********************

DetailID = 1
	Count:    40
	Exception #:  0XC0000008
	Stack:        
		ntdll!KiRaiseUserExceptionDispatcher+0x3a
		vfbasics+0x1158b
		MSWSOCK!WSPSelect+0x588
		WS2_32!select+0x1ac
		qbittorrent!boost::asio::detail::socket_ops::select+0x85 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\socket_ops.ipp @ 1795]
		qbittorrent!boost::asio::detail::select_reactor::run+0x2de [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
		qbittorrent!boost::asio::detail::select_reactor::run_thread+0x68 [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 280]
		qbittorrent!boost::asio::detail::win_thread_function+0x2e [G:\QBITTORRENT\boost_1_72_0\boost\asio\detail\impl\win_thread.ipp @ 127]
		qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
		vfbasics+0x12534
		KERNEL32!BaseThreadInitThunk+0x14
		ntdll!RtlUserThreadStart+0x21

@xavier2k6
Copy link
Member Author

With a new instance of qBittorrent running have had a hit again with also now a break instruction exception encountered too.

(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]

@xavier2k6
Copy link
Member Author

xavier2k6 commented Mar 31, 2020

@sledgehammer999 thoughts? BTW do you use latest b2 when compiling or the one that comes with the boost 1.xx source? just as a matter of interest.

@FranciscoPombal
Copy link
Member

do you use latest b2 when compiling

Does it matter? Just curious.

@xavier2k6
Copy link
Member Author

Does it matter? Just curious.

no, just curious myself...

@xavier2k6
Copy link
Member Author

xavier2k6 commented Apr 3, 2020

This exception is still happening on 4.2.3 (haven't checked earlier versions than 4.2.2 [when first attached], so this exception could always have been there or it may very well be expected too.)

Only noticed this exception when I attached microsofts application verifier to my debugger that's attached to qBittorrent.

@sledgehammer999 is it possible that this is a thread safe issue or something else entirely?

(1e98.1bf4): Invalid handle - code c0000008 (first chance)
[4/3/2020 12:43:30 AM]
  Exception 0XC0000008 on thread 7156. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ff9`96e8158b : 00000000`000003ac 00000084`d05ff360 00000084`d05ff368 00000084`d05ff370 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ff9`b01dec88 : 00000000`00000000 00000000`0000036c 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ff9`b37a1f7c : 00000084`d05ff688 00000084`d05ff688 00007ff9`96eb6ec0 00007ff9`96e74cf2 : MSWSOCK!WSPSelect+0x588
00007ff7`b416d3d5 : 00000279`5e283ff0 00000279`5e16ff98 00000279`5e16fe50 00000279`5e16fe80 : 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]
00007ff7`b418b9b9 : 00000279`5e2a1f01 00000279`5e2a1f00 00000279`5e16fe50 00007ff9`b3b535d0 : qbittorrent!boost::asio::detail::select_reactor::run+0x2f5 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x43 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 279]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::thread_function::operator()+0x47 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 48]
00007ff7`b41049f8 : 00000279`5e2a1fd0 00000000`00000000 00000000`00000000 00000ffe`f6820938 : qbittorrent!boost::asio::detail::win_thread::func<boost::asio::detail::select_reactor::thread_function>::run+0x69 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\win_thread.hpp @ 122]
00007ff7`b4b8ef70 : 00000279`5e291fe0 00000279`5e2a1fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x38 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ff9`96e82534 : 00000279`4d2f1fc0 00000000`00000000 00000279`4d2f1fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ff9`b2967bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007ff9`b3b6ced1 : 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 0x1E98: Invalid handle exception for current stack trace. 

	00000000C0000008 : Exception code.
	00000084D05FEFF0 : Exception record. Use .exr to display it.
	00000084D05FEB00 : Context record. Use .cxr to display it.
	0000000000000000 : Not used.


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

=======================================
(1e98.1bf4): Break instruction exception - code 80000003 (first chance)
  Exception 0X80000003 on thread 7156. DetailID = 2
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ff9`96e72a19 : 00000084`d05fe890 00000279`490808b0 00000000`00000002 00007ff9`b3b47cfd : vrfcore!VerifierStopMessageEx+0x7dc
00007ff9`b3b78636 : 00007ff9`96e72990 00000084`d05fe900 00000279`490808b0 00000000`00000000 : vfbasics+0x2a19
00007ff9`b3b6a0d6 : 00000084`d05feff0 00000084`d05feb00 00000000`00000000 00000000`00000000 : ntdll!RtlpCallVectoredHandlers+0x196
00007ff9`b3b9fe8e : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlDispatchException+0x66
00007ff9`b3b9ff0a : 00000279`4a8f0000 00000000`00000000 00000279`d5aa8aa0 00000000`00000560 : ntdll!KiUserExceptionDispatch+0x2e
00007ff9`96e8158b : 00000000`000003ac 00000084`d05ff360 00000084`d05ff368 00000084`d05ff370 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ff9`b01dec88 : 00000000`00000000 00000000`0000036c 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ff9`b37a1f7c : 00000084`d05ff688 00000084`d05ff688 00007ff9`96eb6ec0 00007ff9`96e74cf2 : MSWSOCK!WSPSelect+0x588
00007ff7`b416d3d5 : 00000279`5e283ff0 00000279`5e16ff98 00000279`5e16fe50 00000279`5e16fe80 : 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]
00007ff7`b418b9b9 : 00000279`5e2a1f01 00000279`5e2a1f00 00000279`5e16fe50 00007ff9`b3b535d0 : qbittorrent!boost::asio::detail::select_reactor::run+0x2f5 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 237]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x43 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 279]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::thread_function::operator()+0x47 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\select_reactor.ipp @ 48]
00007ff7`b41049f8 : 00000279`5e2a1fd0 00000000`00000000 00000000`00000000 00000ffe`f6820938 : qbittorrent!boost::asio::detail::win_thread::func<boost::asio::detail::select_reactor::thread_function>::run+0x69 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\win_thread.hpp @ 122]
00007ff7`b4b8ef70 : 00000279`5e291fe0 00000279`5e2a1fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x38 [g:\qbittorrent\boost_1_72_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ff9`96e82534 : 00000279`4d2f1fc0 00000000`00000000 00000279`4d2f1fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ff9`b2967bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007ff9`b3b6ced1 : 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.

@Chocobo1
Copy link
Member

Chocobo1 commented Apr 3, 2020

See partial stacktrace below - boost asio problem?!

Yes! It should be reported to boost asio or libtorrent. There is nothing qbt can do.

@xavier2k6
Copy link
Member Author

@Chocobo1 thanks, boost 1.73 should be out next week so (it won't be fixed by then as code freeze) will wait & see if that has any effect.....unsure if there's any changes to asio (must look through notes).

@arvidn any thoughts?

@arvidn
Copy link
Contributor

arvidn commented Apr 3, 2020

I think it's might be reasonable to file a ticket with asio for this.

Also, not all structured exceptions are fatal, or even a problem (as long as they are handled near where they were thrown). Does this structured exception actually cause termination of the program or the thread? or some other ill-effect? It's not obvious that just the fact that a structured exception is raised is a problem in and of itself, only if it leaks into libtorrent or qbt, causing threads or the process to shut down.

@xavier2k6
Copy link
Member Author

Opened an issue now with asio #473

@xavier2k6
Copy link
Member Author

xavier2k6 commented Apr 30, 2020

Anyone know how I can go about what to do from below comment?

I'm still experiencing this issue with Boost 1.73 which now uses asio 1.16.1

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.

chriskohlhoff/asio#473 (comment)

[4/30/2020 8:59:44 PM]
  Thread exited. Exiting thread - System ID: 6316. Exit code - 0x00000000
(5fe8.5370): Invalid handle - code c0000008 (first chance)
[4/30/2020 8:59:49 PM]
  Exception 0XC0000008 on thread 23544. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ff8`fbd6158b : 00000000`0000066c 00000069`32dff5a0 00000069`32dff5a8 00000069`32dff5b0 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ff9`221fee18 : 00000000`00000000 00000000`00000694 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007ff9`252c1f7c : 0000019a`d752cfa0 00000000`00000000 00007ff8`fbd96ec0 00007ff8`fbd54cf2 : MSWSOCK!Tcpip4_WSHGetWildcardSockaddr+0x1128
00007ff7`e822006f : 0000019a`ea53aff0 ffffffff`ffffffff 0000019a`ea536ff0 0000019a`ea496f60 : WS2_32!select+0x1ac
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x152 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\socket_ops.ipp @ 1798]
00007ff7`e8220399 : 0000019a`e7324f50 0000019a`e7324f50 00000000`00000001 00007ff7`e8ef28d7 : qbittorrent!boost::asio::detail::select_reactor::run+0x41f [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 238]
00007ff7`e81aae9e : 0000019a`ea54efd0 00000000`00000000 0000019a`ea542fe0 00007ff7`e81aae80 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x89 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 285]
00007ff7`e8edea70 : 0000019a`ea542fe0 0000019a`ea54efd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ff8`fbd62534 : 0000019a`d9e97fc0 00000000`00000000 0000019a`d9e97fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ff9`24247bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007ff9`25b8ce51 : 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 0x5FE8: Invalid handle exception for current stack trace. 

	00000000C0000008 : Exception code.
	0000006932DFF230 : Exception record. Use .exr to display it.
	0000006932DFED40 : Context record. Use .cxr to display it.
	0000000000000000 : Not used.


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

=======================================

socket_ops.ipp#L1798

select_reactor.ipp#L238

select_reactor.ipp#L285

win_thread.ipp#L127

@xavier2k6
Copy link
Member Author

I may have found a cause for this issue - testing ongoing & will report back with my results.

@arvidn
Copy link
Contributor

arvidn commented May 5, 2020

@xavier2k6
if this only happens when attaching application verifier, is there any reason to believe this is an actual problem?

my recollection (but I haven't used application verifier in almost 10 years now) is that there are a lot of structured exceptions (not C++ exceptions) happening internally when using various win32 facilities, but they are always caught and doesn't leak to the user.

If you catch one of these in application verifier, do you have a reason to believe it's not handled by anyone?

If you don't set your debugger to stop on SEH, do you still see a problem?

@xavier2k6
Copy link
Member Author

xavier2k6 commented May 6, 2020

if this only happens when attaching application verifier, is there any reason to believe this is an actual problem?

application verifier only brought the issue to the forefront along with the use of debug diag.
I believe now that the issue is possibly related to the way the GeoIP database file is loaded/handled
(Unfortunatley, there now seems to be issues with downloading of the database - so I can't confirm/continue my testing)

I don't believe this was an issue prior to qBittorrent 4.2.2 as my testing couldn't reproduce it (prior to 4.2.2 - qBittorrent was using a different GeoIP database)

my recollection (but I haven't used application verifier in almost 10 years now) is that there are a lot of structured exceptions (not C++ exceptions) happening internally when using various win32 facilities, but they are always caught and doesn't leak to the user.

That may be so.....

If you catch one of these in application verifier, do you have a reason to believe it's not handled by anyone?

It's not caught by application verifier per se but with the debugger tool debug diag - I haven't been able to confirm if now only debug diag catches it on it's own.

If you don't set your debugger to stop on SEH, do you still see a problem?

I haven't set it to stop & it continues but it can reach 162 instances of this error, that to me is excessive even if it is expected.

***********************
*  EXCEPTION SUMMARY  *
***********************

	|--------------------|
	| Count | Exception  |
	|--------------------|
	| 162   | 0XC0000008 |

I haven't seen anything that says "ok, this is expected & can be ignored" etc

It could very well be a false positive so to speak or it could very well be a genuine issue & until there's a definitive answer then obviously the issue will have to remain open & further testing/debugging will be ongoing....

@xavier2k6
Copy link
Member Author

@milgradesec since you experienced this too, anything you could add to this would be very much appreciated, testing/findings etc etc

@arvidn
Copy link
Contributor

arvidn commented May 6, 2020

I haven't set it to stop & it continues but it can reach 162 instances of this error, that to me is excessive even if it is expected.

I don't think it's reasonable to make assumptions about what a "normal" number of structured exceptions will be raised during a program. This is an implementation detail (until the exception leaks out of select()), does it?

I haven't seen anything that says "ok, this is expected & can be ignored" etc

But only the implementer of select() could tell you that, more importantly, if this exception doesn't leak out of the call to select(), it does not matter. The fact that a structured exception is raised isn't a problem in and of itself. No more so than some functions returning non-zero sometimes.

I haven't seen anything in this ticket explaining what the actual problem is, other than a structure exception happens. Although, it does say "Unhandled exception" in a few places. Is it unhandled? If you continue the process after this happens, does it terminate?

If so, that would definitely be a problem; qBT crashing.

@xavier2k6
Copy link
Member Author

I set the application verifier to stop in conjunction with my debugger & received a C0000008 followed by a C0000421 & qBittorrent crashed/created a minidump..

All along it was set to continue.......

@arvidn I may be wrong in my terminology of C0000008 being an unhandled exception since it's more of an invalid handle

This is an implementation detail (until the exception leaks out of select()), does it?

But only the implementer of select() could tell you that, more importantly, if this exception doesn't leak out of the call to select()

I'll be honest with you - this is above my pay grade as the saying goes.....
Can you explain? (If you have the time, thanks)

[5/8/2020 6:44:37 PM]
  Thread exited. Exiting thread - System ID: 13112. Exit code - 0x00000000
(2b88.176c): Invalid handle - code c0000008 (first chance)
[5/8/2020 6:44:39 PM]
  Exception 0XC0000008 on thread 11060. DetailID = 2
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007fff`4a02158b : 00000000`000006a4 0000008e`e43ff220 0000008e`e43ff228 0000008e`e43ff230 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007fff`67e3ee18 : 00000000`00000000 00000000`000006b4 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007fff`6a391f7c : 000001c2`8ed97fa0 00000000`00000000 00007fff`4a056ec0 00007fff`4a014cf2 : MSWSOCK!Tcpip4_WSHGetWildcardSockaddr+0x1128
00007ff7`b5ec012f : 000001c2`8ecafff0 ffffffff`ffffffff 000001c2`8eca7ff0 000001c2`8eb93f60 : WS2_32!select+0x1ac
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x152 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\socket_ops.ipp @ 1798]
00007ff7`b5ec0459 : 000001c2`8b494f50 000001c2`8b494f50 00000000`00000001 00007ff7`b6b92ab7 : qbittorrent!boost::asio::detail::select_reactor::run+0x41f [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 238]
00007ff7`b5e4af5e : 000001c2`8eccbfd0 00000000`00000000 000001c2`8ecbbfe0 00007ff7`b5e4af40 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x89 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 285]
00007ff7`b6b7ec50 : 000001c2`8ecbbfe0 000001c2`8eccbfd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007fff`4a022534 : 000001c2`fdfe7fc0 00000000`00000000 000001c2`fdfe7fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007fff`69ee7bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007fff`6b7cce51 : 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 0x2B88: Invalid handle exception for current stack trace. 

	00000000C0000008 : Exception code.
	0000008EE43FEEB0 : Exception record. Use .exr to display it.
	0000008EE43FE9C0 : Context record. Use .cxr to display it.
	0000000000000000 : Not used.


=======================================
This verifier stop is not continuable. Process will be terminated 
when you use the `go' debugger command.

=======================================

(2b88.176c): Verifier stop - code c0000421 (first chance)
  Exception 0XC0000421 on thread 11060. DetailID = 3
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007fff`4a012a19 : 0000008e`e43fe750 000001c2`f9bd08b0 00000000`00000002 00007fff`6b7a7c7d : vrfcore!VerifierStopMessageEx+0x7cb
00007fff`6b7d85b6 : 00007fff`4a012990 0000008e`e43fe700 000001c2`f9bd08b0 00000000`00000000 : vfbasics+0x2a19
00007fff`6b7ca056 : 0000008e`e43feeb0 0000008e`e43fe9c0 00000000`00000000 00000000`00000000 : ntdll!RtlIsGenericTableEmpty+0x1a6
00007fff`6b7ffe3e : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlRaiseException+0x1e6
00007fff`6b7ffeba : 000001c2`fb440000 00000000`00000000 000001c3`826a2a60 00000000`000005a0 : ntdll!KiUserExceptionDispatcher+0x2e
00007fff`4a02158b : 00000000`000006a4 0000008e`e43ff220 0000008e`e43ff228 0000008e`e43ff230 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007fff`67e3ee18 : 00000000`00000000 00000000`000006b4 00000000`00000000 00000000`00000000 : vfbasics+0x1158b
00007fff`6a391f7c : 000001c2`8ed97fa0 00000000`00000000 00007fff`4a056ec0 00007fff`4a014cf2 : MSWSOCK!Tcpip4_WSHGetWildcardSockaddr+0x1128
00007ff7`b5ec012f : 000001c2`8ecafff0 ffffffff`ffffffff 000001c2`8eca7ff0 000001c2`8eb93f60 : WS2_32!select+0x1ac
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x152 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\socket_ops.ipp @ 1798]
00007ff7`b5ec0459 : 000001c2`8b494f50 000001c2`8b494f50 00000000`00000001 00007ff7`b6b92ab7 : qbittorrent!boost::asio::detail::select_reactor::run+0x41f [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 238]
00007ff7`b5e4af5e : 000001c2`8eccbfd0 00000000`00000000 000001c2`8ecbbfe0 00007ff7`b5e4af40 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x89 [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\select_reactor.ipp @ 285]
00007ff7`b6b7ec50 : 000001c2`8ecbbfe0 000001c2`8eccbfd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [C:\QBITTORRENT\boost_1_73_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007fff`4a022534 : 000001c2`fdfe7fc0 00000000`00000000 000001c2`fdfe7fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007fff`69ee7bd4 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x12534
00007fff`6b7cce51 : 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.
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
(2b88.176c): Verifier stop - code c0000421 (!!! second chance !!!)
Creating C:\Program Files\DebugDiag\Logs\Crash Dumps for all instances of qbittorrent.exe\qbittorrent__PID__11144__Date__05_08_2020__Time_06_44_39PM__489__Second_Chance_Exception_C0000421.dmp - mini user dump
Dump successfully written
[5/8/2020 6:45:08 PM]
  Second chance exception - 0XC0000421 caused by thread with System ID: 11060 DetailID = 3

@xavier2k6 xavier2k6 changed the title Unhandled exception 0xC0000008 with 4.2.2 Invalid Handle exception 0xC0000008 with 4.2.2 May 9, 2020
@milgradesec
Copy link

It seems and invalid handle to a socket is given to WinSock select(), maybe some socket is closed and its handle still kept

@arvidn
Copy link
Contributor

arvidn commented May 9, 2020

This is an implementation detail (until the exception leaks out of select()), does it?

But only the implementer of select() could tell you that, more importantly, if this exception doesn't leak out of the call to select()

I'll be honest with you - this is above my pay grade as the saying goes.....
Can you explain? (If you have the time, thanks)

I just mean that (at least in my experience); the debugger detecting that a SEH is raised is not necessarily a sign of a problem, because those are raised as part of normal operations. Only if a structured exception actually causes the program to terminate/crash is it a problem.

I might be wrong here, but from your description it sounds like you found this only in the debugger. But, again, I'm not sure.

When you run qBT without a debugger, does it crash?

@arvidn
Copy link
Contributor

arvidn commented May 9, 2020

This seems to suggest; "yes, the exception causes the process to terminate"

(2b88.176c): Verifier stop - code c0000421 (!!! second chance !!!)
Creating C:\Program Files\DebugDiag\Logs\Crash Dumps for all instances of qbittorrent.exe\qbittorrent__PID__11144__Date__05_08_2020__Time_06_44_39PM__489__Second_Chance_Exception_C0000421.dmp - mini user dump
Dump successfully written
[5/8/2020 6:45:08 PM]
  Second chance exception - 0XC0000421 caused by thread with System ID: 11060 DetailID = 3

@FranciscoPombal
Copy link
Member

@xavier2k6 What's the status on this one? Can you still reproduce with 4.3.0.1?

@xavier2k6
Copy link
Member Author

@xavier2k6 What's the status on this one? Can you still reproduce with 4.3.0.1?

It was still happening with master - however, I've updated to 20H2 & the appverifier won't actually open......will have to test on another machine when I get a chance.

@FranciscoPombal FranciscoPombal added the OS: Windows Issues specific to Windows label Oct 22, 2020
@xavier2k6
Copy link
Member Author

It's still there with 4.3.0.1/Boost 1.74, anything we can do about suggestion from chriskohlhoff/asio#473 (comment)?

[11/21/2020 6:38:59 PM]
  Exception 0XC0000008 on thread 14320. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ffb`63ca215b : 00000000`000006d4 000000e3`49dfeee0 000000e3`49dfeee8 000000e3`49dfeef0 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ffb`87a5f1ab : 00000000`00000001 00000000`000006ec 00000000`00000000 00000000`00000000 : vfbasics+0x1215b
00007ffb`8a0d16f7 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000001 : MSWSOCK!WSPSelect+0x52b
00007ff6`da7c19ff : 00000000`00000000 00000222`b95abe50 00000222`b95abfc8 ffffffff`ffffffff : WS2_32!select+0x137
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x79 [C:\QBITTORRENT\boost_1_74_0\boost\asio\detail\impl\socket_ops.ipp @ 2195]
00007ff6`da7c1de9 : 00000222`b2987f50 00000222`b2987f50 00000000`00000001 00007ff6`db3b6f3b : qbittorrent!boost::asio::detail::select_reactor::run+0x35f [C:\QBITTORRENT\boost_1_74_0\boost\asio\detail\impl\select_reactor.ipp @ 238]
00007ff6`da7546ee : 00000222`b95d9fd0 00000000`00000000 00000222`c66d9fe0 00007ff6`da7546d0 : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x89 [C:\QBITTORRENT\boost_1_74_0\boost\asio\detail\impl\select_reactor.ipp @ 285]
00007ff6`db3ab630 : 00000222`c66d9fe0 00000222`b95d9fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x2e [C:\QBITTORRENT\boost_1_74_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ffb`63ca6a74 : 00000222`b47effc0 00000000`00000000 00000222`b47effc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ffb`89fe7034 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x16a74
00007ffb`8ac3cec1 : 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.

@FranciscoPombal
Copy link
Member

@xavier2k6 ping, still reproducible in latest master + latest RC_1_2 + boost 1.75?

@xavier2k6
Copy link
Member Author

xavier2k6 commented Dec 18, 2020

@xavier2k6 ping, still reproducible in latest master + latest RC_1_2 + boost 1.75?

I haven't the time currently to build/test...

EDIT: #13203 is basically a dupe of this.

@xavier2k6
Copy link
Member Author

Got around to testing this with 4.3.3 & it still happens!

[3/3/2021 2:08:08 PM]
  Thread created. New thread - System ID: 12788
(2ba4.2b50): Invalid handle - code c0000008 (first chance)
[3/3/2021 2:08:31 PM]
  Exception 0XC0000008 on thread 1472. DetailID = 1
  Stack Trace
RetAddr           : Args to Child                                                           : Call Site
00007ffb`9fdd215b : 00000000`000007ec 000000f8`dddff4a0 000000f8`dddff4a8 000000f8`dddff4b0 : ntdll!KiRaiseUserExceptionDispatcher+0x3a
00007ffb`b94df1ab : 00000000`00000001 00000000`000007fc 00000000`00000000 00000000`00000000 : vfbasics+0x1215b
00007ffb`baf016f7 : 00000000`00000000 000000f8`dddff7b8 000000f8`dddff7b0 00000000`00000000 : MSWSOCK!WSPSelect+0x52b
00007ff6`6a0ee64e : 00000000`00000000 00000000`00000000 00000249`09236e50 00000249`09236f98 : WS2_32!select+0x137
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::socket_ops::select+0x78 [g:\qbittorrent\boost_1_75_0\boost\asio\detail\impl\socket_ops.ipp @ 2195]
00007ff6`6a10aec9 : 00000249`139c6f01 00000249`139c6f00 00000249`09236e50 00007ffb`bc6c07b0 : qbittorrent!boost::asio::detail::select_reactor::run+0x2fe [g:\qbittorrent\boost_1_75_0\boost\asio\detail\impl\select_reactor.ipp @ 238]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::run_thread+0x43 [g:\qbittorrent\boost_1_75_0\boost\asio\detail\impl\select_reactor.ipp @ 284]
(Inline Function) : --------`-------- --------`-------- --------`-------- --------`-------- : qbittorrent!boost::asio::detail::select_reactor::thread_function::operator()+0x47 [g:\qbittorrent\boost_1_75_0\boost\asio\detail\impl\select_reactor.ipp @ 48]
00007ff6`6a08f218 : 00000249`139c6fd0 00000000`00000000 00000000`00000000 00000ffe`cd411e3c : qbittorrent!boost::asio::detail::win_thread::func<boost::asio::detail::select_reactor::thread_function>::run+0x69 [g:\qbittorrent\boost_1_75_0\boost\asio\detail\win_thread.hpp @ 122]
00007ff6`6aa60a10 : 00000249`139bcfe0 00000249`139c6fd0 00000000`00000000 00000000`00000000 : qbittorrent!boost::asio::detail::win_thread_function+0x38 [g:\qbittorrent\boost_1_75_0\boost\asio\detail\impl\win_thread.ipp @ 127]
00007ffb`9fdd6a74 : 00000249`7ebb5fc0 00000000`00000000 00000249`7ebb5fc0 00000000`00000000 : qbittorrent!thread_start<unsigned int (__cdecl*)(void *),1>+0x50 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
00007ffb`bbd97034 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : vfbasics+0x16a74
00007ffb`bc6c2651 : 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.

@xavier2k6
Copy link
Member Author

xavier2k6 commented Mar 3, 2021

To maybe shed some light on this issue - checking the logs for around that time (I had run out of space)

(W) 2021-03-03T14:05:39 - File error alert. Torrent: "Some Torrent". File: "G:\Tv\Some Torrent\Some Torrent.mkv". Reason: Some Torrent file_open (G:\Tv\Some Torrent\Some Torrent.mkv) error: There is not enough space on the disk
(W) 2021-03-03T14:05:39 - File error alert. Torrent: "Some Torrent". File: "G:\Tv\Some Torrent\Some Torrent.mkv". Reason: Some Torrent file_open (G:\Tv\Some Torrent\Some Torrent.mkv) error: There is not enough space on the disk
(W) 2021-03-03T14:08:34 - File error alert. Torrent: "Some Torrent". File: "G:\Tv\Some Torrent\Subs\Some Torrent.idx". Reason: Some Torrent file_write (G:\Tv\Some Torrent\Subs\Some Torrent.idx) error: There is not enough space on the disk

I was torrenting normally but I was also force rechecking torrents.....

EDIT: pre-allocate disk space for all files enabled

@rugabunda
Copy link

rugabunda commented Apr 17, 2022

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;

@xavier2k6
Copy link
Member Author

@rugabunda thanks for the suggestion.......will re-test/look in to this when free-time permits.

@arvidn
Copy link
Contributor

arvidn commented Apr 17, 2022

I think there's a fundamental issue with this ticket. It's failing to communicate what the problem is. The original report says the expected behavior is to not have an unhandled exception. But none of the evidence presented suggests that there is an unhandled exception. Only that there is and exception, inside select(), which presumably is handled by select() and turned into a WSAENOSOCK error.

It seem the premise is that when enabling a debugging feature that stops on all windows exceptions (SEH), the program should never break into the debugger. I don't think that's a reasonable expectation, and I haven't heard an argument why that would be a reasonable expectation.

Does anyone not enabling these debug functions have a problem with this?

@xavier2k6
Copy link
Member Author

@arvidn The original issue was discovered when I was trying to figure out why some users were experiencing crashes but there was no stack trace provided as qbittorrent just seemed to disappear/CTD. (if I recall correctly)

The invalid handle would in some cases eventually lead to a crash ref.: #12329 (comment)

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 also seems to suggest it's still crashing & user has provided crash dumps in tickets they opened.

The only thing that I can find in said crash dumps is the 0xC0000008 but nothing else to go on in them.

(1x of the dumps won't actually download as it keeps getting flagged as a virus! - so this could be where the users problem lies or it could also be that from the dumps it seems they're running the 32-bit version)

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.

I carried out these steps on master build & so far haven't been able to re-produce 0xC0000008??


@rugabunda

You may need to run a virus/malware scan.

Can you provide more details about version of 4.4.2 you are using? (Qt5 or Qt6 / libtorrent 1.2.15 or 2.0.5)
{Boost 1.78} is being used in 4.4.2

@UnknownzD
Copy link

UnknownzD commented May 30, 2022

Sorry, I can still produce the whole issue on Windows Server 2022, running 4.4.3.1 with QT6 & libtorrent 2.X branch.

Please see below image for your reference.
qbittorrent crash

It seems that the crash started very soon once the thread is created, but I am not sure what invalidated handle was being re-used.

In addition, I can confirm that I have following security mitigation / exploit guard in place which resulted in the crash, but I would rather choose not to disable it at the moment.

Set-ProcessMitigation -System -Enable StrictHandle -Force On

Please see if there is any reason why an invalid handle is being re-used by the program once a new thread is created.

@arvidn The above security mitigation setting is to prevent the program re-using the handle that has already be freed or invalidated, which is a correct measurement to reduce the attack surface on Windows.

@arvidn
Copy link
Contributor

arvidn commented May 30, 2022

@UnknownzD what does that screenshot illustrate?

It seems that the crash started very soon once the thread is created, but I am not sure what invalidated handle was being re-used.

Are you referring to the internal asio thread for the select interrupter?

there are legitimate reasons for those sockets to become invalid. When they do, they need to be re-created. For example, if the system hibernates, sockets may be closed behind the process' back.

See this commit to asio: chriskohlhoff/asio@4b37bdb

It doesn't sound like this happens to you when your system goes to sleep though. Do you have any other hints of what might cause the interrupter socket to be closed? (it's a long-lived socket bound to loopback).

@luzpaz
Copy link
Contributor

luzpaz commented Sep 2, 2024

@xavier2k6 can you weigh-in here when you get a chance?

@xavier2k6
Copy link
Member Author

@xavier2k6 can you weigh-in here when you get a chance?

I haven't used app verifier in a while or looked in to this further, it may or may not have relevance to #17082

I do know though that asio which is apart of Boost & used by libtorrent to initilaize the winsock was using a DRAFT version of 2.0 for Boost <=1.84.0, it was changed to 2.2 in Boost 1.85.0 via chriskohlhoff/asio#1436

template <int Major = 2, int Minor = 0>
class winsock_init : private winsock_init_base

https://www.boost.org/doc/libs/1_84_0/boost/asio/detail/winsock_init.hpp


template <int Major = 2, int Minor = 2>
class winsock_init : private winsock_init_base

https://www.boost.org/doc/libs/1_85_0/boost/asio/detail/winsock_init.hpp

@xavier2k6
Copy link
Member Author

#16407 & #16618 are related/duplicate.

@xavier2k6
Copy link
Member Author

Looks like Qt are also using 2.0 for winsock initialization/startup in certain places.

QWindowsSockInit::QWindowsSockInit()
:   version(0)
{
    //### should we try for 2.2 on all platforms ??
    WSAData wsadata;

    // IPv6 requires Winsock v2.0 or better.
    if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) {
        qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
    } else {
        version = 0x20;
    }
}

@xavier2k6
Copy link
Member Author

Looks like Qt are also using 2.0 for winsock initialization/startup in certain places.

QWindowsSockInit::QWindowsSockInit()
:   version(0)
{
    //### should we try for 2.2 on all platforms ??
    WSAData wsadata;

    // IPv6 requires Winsock v2.0 or better.
    if (WSAStartup(MAKEWORD(2, 0), &wsadata) != 0) {
        qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed.");
    } else {
        version = 0x20;
    }
}

Changes have been made/merged upstream & Winsock will be initialized with 2.2 as of Qt 6.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash OS: Windows Issues specific to Windows
Projects
None yet
Development

No branches or pull requests

8 participants