Skip to content

System.Runtime.InteropServices.SEHException when trying to run multiple instances. #100

@alandixon

Description

@alandixon

Specifically, I'm using the MultipleInstances demo project.

The variable parallelInstances is set to 4 by default.
For this value and any other value over 2, I intermittently get the SEHException, usually around the time everything starts to tear down.

After quite a lot of fiddling, I'm fairly sure the problem is to do with the virtual desktops;
If I force TorSharpSettings.ToolRunnerType to return ToolRunnerType.Simple, the problem goes away.
Of course, if I do that, I get a lot of popup privoxy windows, but it proves the point.

I am using Windows 10 64-bit which is why the ToolRunnerType defaults to VirtualDesktop.

I've tried lock in a few places to force single threading but not managed to isolate a vulnerable area of code.

The message is:

System.Runtime.InteropServices.SEHException
  HResult=0x80004005
  Message=External component has thrown an exception.

and the stack trace in Visual Studio 2022 is:

[Exception] System.Private.CoreLib.dll!Microsoft.Win32.SafeHandles.SafeFileHandle.ReleaseHandle()
[Exception] System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.InternalRelease(bool disposeOrFinalizeOperation)
[Exception] System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.Dispose(bool disposing)
[Exception] System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.~SafeHandle()
[Managed to Native Transition]	
System.Private.CoreLib.dll!Interop.Kernel32.CloseHandle(System.IntPtr handle)
System.Private.CoreLib.dll!Microsoft.Win32.SafeHandles.SafeFileHandle.ReleaseHandle()
System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.InternalRelease(bool disposeOrFinalizeOperation)
System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.Dispose(bool disposing)
System.Private.CoreLib.dll!System.Runtime.InteropServices.SafeHandle.~SafeHandle()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions