rodneyviana / blogdemos

Demo projects/binaries for my MSDN blog at https://blogs.msdn.microsoft.com
MIT License
7 stars 2 forks source link

SourceExt does not reach DebugExtensionInitialize #1

Open EveryOtherUsernameWasAlreadyTaken opened 4 years ago

EveryOtherUsernameWasAlreadyTaken commented 4 years ago

I downloaded the code of SourceExt and compiled as 32 Bit extension (just as it was, but using VS 2019). The extension does not reach DebugExtensionInitialize(). I tried with WinDbg Preview, WinDbg from 10.0 SDK, 8.1 SDK and 8.0 SDK.

So it turns out that

Though I believe I resolved the issue,

is not true and

it may be necessary that you copy the extension to the very same folder where WinDBG is located.

is still required. However, for WinDbg Preview, it's not so simple to copy files into the same folder as the app.

EveryOtherUsernameWasAlreadyTaken commented 4 years ago

This is the series of exceptions thrown in the debugger (WinDbg Preview, DbgX.Shell.exe) until it shows the message

The engine has been disconnected unexpectedly.

0:014> .loadby sos clr
0:014> !pe
Exception object: 000001f25aec0af8
Exception type:   WindowsDebugger.RpcDisconnectedException
Message:          RPC disconnection error during operation: ExecuteWide
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80131500

0:014> !pe
Exception object: 000001f25aec0af8
Exception type:   WindowsDebugger.RpcDisconnectedException
Message:          RPC disconnection error during operation: ExecuteWide
InnerException:   <none>
StackTrace (generated):
    SP               IP               Function
    0000006222DFEE00 00007FF941FEBC64 UNKNOWN!WindowsDebugger.DbgEng.HRESULTExtensions.ThrowOnDisconnected(WindowsDebugger.DbgEng.HRESULT, System.String)+0x64
    0000006222DFEE40 00007FF941FEB6D9 UNKNOWN!DbgX.Requests.ExecuteRequest.DoExecute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0x1a9
    0000006222DFEEC0 00007FF941E1898C UNKNOWN!DbgX.Requests.EngineRequestWithTask`1[[System.Boolean, mscorlib]].Execute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0x5c

StackTraceString: <none>
HResult: 80131500

0:000> !pe
Exception object: 000001f25aec0af8
Exception type:   WindowsDebugger.RpcDisconnectedException
Message:          RPC disconnection error during operation: ExecuteWide
InnerException:   <none>
StackTrace (generated):
    SP               IP               Function
    0000006222DFEE00 00007FF941FEBC64 UNKNOWN!WindowsDebugger.DbgEng.HRESULTExtensions.ThrowOnDisconnected(WindowsDebugger.DbgEng.HRESULT, System.String)+0x64
    0000006222DFEE40 00007FF941FEB6D9 UNKNOWN!DbgX.Requests.ExecuteRequest.DoExecute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0x1a9
    0000006222DFEEC0 00007FF941E189E5 UNKNOWN!DbgX.Requests.EngineRequestWithTask`1[[System.Boolean, mscorlib]].Execute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0xb5
    0000006222DFEF00 00007FF941E201EC UNKNOWN!DbgX.EngineThread.ExecuteRequestAndLog(DbgX.Requests.EngineRequest)+0x15c
    0000006221D7DC30 00007FF9A0318E70 mscorlib_ni!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+0x20
    0000006221D7DC60 00007FF99F9B9AAE mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)+0x3e
    0000006221D7DC90 00007FF941FE9D5F UNKNOWN!DbgX.Debugger.Services.ConsoleService+<ExecuteCommandAsync>d__14.MoveNext()+0x33f

StackTraceString: <none>
HResult: 80131500

0:014> !pe
Exception object: 000001f25aec0af8
Exception type:   WindowsDebugger.RpcDisconnectedException
Message:          RPC disconnection error during operation: ExecuteWide
InnerException:   <none>
StackTrace (generated):
    SP               IP               Function
    0000006222DFEE00 00007FF941FEBC64 UNKNOWN!WindowsDebugger.DbgEng.HRESULTExtensions.ThrowOnDisconnected(WindowsDebugger.DbgEng.HRESULT, System.String)+0x64
    0000006222DFEE40 00007FF941FEB6D9 UNKNOWN!DbgX.Requests.ExecuteRequest.DoExecute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0x1a9
    0000006222DFEEC0 00007FF941E189E5 UNKNOWN!DbgX.Requests.EngineRequestWithTask`1[[System.Boolean, mscorlib]].Execute(DbgX.Requests.IEngineRequestServices, DbgX.EngineInterfaces)+0xb5
    0000006222DFEF00 00007FF941E201EC UNKNOWN!DbgX.EngineThread.ExecuteRequestAndLog(DbgX.Requests.EngineRequest)+0x15c
    0000006221D7DC30 00007FF9A0318E70 mscorlib_ni!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+0x20
    0000006221D7DC60 00007FF99F9B9AAE mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)+0x3e
    0000006221D7DC90 00007FF941FE9D5F UNKNOWN!DbgX.Debugger.Services.ConsoleService+<ExecuteCommandAsync>d__14.MoveNext()+0x33f
    0000006221D7DC40 00007FF9A0318E70 mscorlib_ni!System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()+0x20
    0000006221D7DC70 00007FF99F9B9AAE mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)+0x3e
    0000006221D7DCA0 00007FF941FE979F UNKNOWN!DbgXUI.ToolWindows.CommandViewModel+<ExecuteCommandAsync>d__133.MoveNext()+0x13f

StackTraceString: <none>
HResult: 80131500

0:014> !pe
Exception object: 000001f25acfca00
Exception type:   System.InvalidCastException
Message:          Unable to cast COM object of type 'System.__ComObject' to interface type 'WindowsDebugger.DbgEng.IDebugSettings'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9D339BE5-30CD-4403-92C3-57EA33799CB1}' failed due to the following error: The call was not transmitted properly; the message queue was full and was not emptied after yielding. (Exception from HRESULT: 0x8001000A (RPC_E_CANTTRANSMIT_CALL)).
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80004002

0:014> !pe
Exception object: 000001f25ada0608
Exception type:   System.InvalidOperationException
Message:          Cannot process request because the process (17016) has exited.
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80131509

0:000> !pe
Exception object: 000001f25af5c158
Exception type:   System.Threading.Tasks.TaskCanceledException
Message:          A task was canceled.
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 8013153b

0:000> !pe
Exception object: 000001f25af5c158
Exception type:   System.Threading.Tasks.TaskCanceledException
Message:          A task was canceled.
InnerException:   <none>
StackTrace (generated):
    SP               IP               Function
    0000006221D7DC20 00007FF9A0712CEA mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)+0xd5918a
    0000006221D7DC60 00007FF99F9B9AAE mscorlib_ni!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)+0x3e
    0000006221D7DC90 00007FF941FE9D5F UNKNOWN!DbgX.Debugger.Services.ConsoleService+<ExecuteCommandAsync>d__14.MoveNext()+0x33f

StackTraceString: <none>
HResult: 8013153b
rodneyviana commented 3 years ago

Sorry for the delay. I normally don't follow this project as it is just a repository for my blog and I did not even remember adding SourceExt here. Please use NetExt instead which should contain all SourceExt commands and some. SourceExt is something very targeted to a particular environment and was never designed to work on 32-bits.

rodneyviana commented 3 years ago

Anyway, this error seems to be related to race condition or lack of ComInitialize.

WindowsDebugger.DbgEng.IDebugSettings'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9D339BE5-30CD-4403-92C3-57EA33799CB1}' failed due to the following error: The call was not transmitted properly; the message queue was full and was not emptied after yielding. (Exception from HRESULT: 0x8001000A (RPC_E_CANTTRANSMIT_CALL))