Skip to content

Instantly share code, notes, and snippets.

@WimObiwan
Last active October 19, 2021 08:16
Show Gist options
  • Save WimObiwan/5d4e88316f6727cde8f96ac651c647b2 to your computer and use it in GitHub Desktop.
Save WimObiwan/5d4e88316f6727cde8f96ac651c647b2 to your computer and use it in GitHub Desktop.
WinDbg troubleshoot deadlocks caused by WinForms STA-violations
* START EXE IN WINDBG
* Based on https://web.archive.org/web/20160223063851/http://blogs.msdn.com/b/dsui_team/archive/2012/10/31/debugging-windows-forms-application-hangs-during-systemevents.userpreferencechanged.aspx
sxe ld clrjit
g
.sympath srv*http://msdl.microsoft.com/download/symbols
.reload
.loadby sos.dll clr
* If above command fails, run ("g"), and one second later, press the break button. Then try the .loadby command again
!name2ee System_Windows_Forms_ni System.Windows.Forms.Application+MarshalingControl..ctor
* LOOK FOR "JITTED Code Address:" e.g. "JITTED Code Address: 647ad2b4"
* Replace "xxxxxxxx" by that address e.g. 647ad2b4
bp xxxxxxxx ".echo MarshalingControl creation detected. Callstack follows.;!clrstack;.echo ==============================;gc"
g
* Analyze every output of "MarshalingControl creation detected. Callstack follows."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment