Asynchronous thread abort on Editor close

Started by Crimson Wizard, Mon 18/03/2013 08:34:38

Previous topic - Next topic

Crimson Wizard

I have no idea if that's important, just thought I'll post this here.
If run under MSVS with "Managed Debugging Assistants" enabled (Debug -> Exceptions) the Editor invokes following warning every time it closes:

Quote
Managed Debugging Assistant 'AsynchronousThreadAbort' has detected a problem in '<...>\Editor\AGS.Editor\bin\Debug\AGSEditor.vshost.exe'.
Additional Information: User code running on thread XXXX has attempted to abort thread YYYY. This may result in a corrupt state or resource leaks if the thread being aborted was in the middle of an operation that modifies global state or uses native resources. Aborting threads other than the currently running thread is strongly discouraged.

Thread id are always different, ofc.
This happens with all versions of AGS I've tried (3.2.1, 3.2.2, github).

Callstack:
Quote
   mscorlib.dll!System.Threading.Thread.Abort() + 0x20 bytes   
   AGSEditor.exe!AGS.Editor.NamedPipesServer.Stop() Line 121 + 0xd bytes   C#
   AGSEditor.exe!AGS.Editor.NamedPipesEngineCommunication.Dispose() Line 123 + 0xd bytes   C#
   AGSEditor.exe!AGS.Editor.DebugController.EditorShutdown() Line 204 + 0xc bytes   C#
   AGSEditor.exe!AGS.Editor.AGSEditor.Dispose() Line 210 + 0xd bytes   C#
   AGSEditor.exe!AGS.Editor.GUIController._mainForm_OnEditorShutdown() Line 1508 + 0xd bytes   C#
   AGSEditor.exe!AGS.Editor.frmMain.frmMain_FormClosing(object sender = {AGS.Editor.frmMain}, System.Windows.Forms.FormClosingEventArgs e = {System.Windows.Forms.FormClosingEventArgs}) Line 408 + 0x17 bytes   C#
   System.Windows.Forms.dll!System.Windows.Forms.Form.OnFormClosing(System.Windows.Forms.FormClosingEventArgs e) + 0x77 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Form.RaiseFormClosingOnAppExit() + 0xf4 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.ExitInternal() + 0xe7 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.Exit(System.ComponentModel.CancelEventArgs e = null) + 0x4e bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.Exit() + 0x7 bytes   
   AGSEditor.exe!AGS.Editor.GUIController.ShowWelcomeScreen() Line 856 + 0x5 bytes   C#
   AGSEditor.exe!AGS.Editor.frmMain.frmMain_Shown(object sender = {AGS.Editor.frmMain}, System.EventArgs e = {System.EventArgs}) Line 435 + 0x12 bytes   C#
   System.Windows.Forms.dll!System.Windows.Forms.Form.OnShown(System.EventArgs e) + 0x7a bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Form.CallShownEvent() + 0x20 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x76 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) + 0x69 bytes   
   mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x51 bytes   
   [Native to Managed Transition]   
   [Managed to Native Transition]   
   mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x67 bytes   
   mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x45 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x69 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() + 0xc3 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x12f bytes   
   System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x2a bytes   
   System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) + 0x10 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) + 0x40 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x10 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, int msg = 0x0000c23f, System.IntPtr wparam, System.IntPtr lparam) + 0x5a bytes   
   [Native to Managed Transition]   
   [Managed to Native Transition]   
   System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = 0xffffffff, int pvLoopData = 0x00000000) + 0x24e bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = 0xffffffff, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x177 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes   
   System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes   
   AGSEditor.exe!AGS.Editor.GUIController.StartGUI(string[] commandLineArguments = {string[0x00000000]}) Line 1369 + 0xb bytes   C#
   AGSEditor.exe!AGS.Editor.ApplicationController.StartGUI(string[] commandLineArguments = {string[0x00000000]}) Line 123 + 0x10 bytes   C#
   AGSEditor.exe!AGS.Editor.Program.RunApplication(string[] args = {string[0x00000000]}) Line 55 + 0x10 bytes   C#
   AGSEditor.exe!AGS.Editor.Program.Main(string[] args = {string[0x00000000]}) Line 23 + 0x8 bytes   C#
   [Native to Managed Transition]   
   [Managed to Native Transition]   
   mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x3a bytes   
   Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2b bytes   
   mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes   
   mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes   
   mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes   

Calin Leafshade

I would imagine thats the GUI thread stopping the debugger thread that waits for input from the engine.

Named pipes shouldn't be an issue resource wise so I don't think this is a problem. Arguably the thread should stop itself though just for cleaness.

I think we should probably get rid of the named pipes altogether though and replace them with a TCP debugging interface. Name pipes are a windows-only solution.

SMF spam blocked by CleanTalk