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

System.ObjectDisposedException: Safe handle has been closed #75

Open
NPM-Chris opened this issue Sep 15, 2023 · 1 comment
Open

System.ObjectDisposedException: Safe handle has been closed #75

NPM-Chris opened this issue Sep 15, 2023 · 1 comment

Comments

@NPM-Chris
Copy link

I have been getting the following error when opening up Bonsai files with only the "Device (Bonsai.Harp)" node with the PortName specified:

Unhandled Exception: System.ObjectDisposedException: Safe handle has been closed
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
at Microsoft.Win32.UnsafeNativeMethods.SetCommMask(SafeFileHandle hFile, Int32 dwEvtMask)
at System.IO.Ports.SerialStream.Dispose(Boolean disposing)
at System.IO.Ports.SerialStream.Finalize()

Following the exception, all Bonsai windows close.

The issue appears fairly reproduceable by following the following steps:

  1. Open Bonsai
  2. Open an existing file with only a "Device (Bonsai.Harp)" node without the PortName specified.
  3. Using "File -> Open..." open an existing file in another folder which only has a "Device (Bonsai.Harp)" node with the PortName specified.

Most of the time following these steps cause the command window to initially populate with the WhoAmI information then shortly after populate with the exception followed by all Bonsai windows closing. I have not been able to reproduce when opening a file within the same folder, it appears that the opening of files in a different folder is treated differently than files in the same folder.

Versioning: These tests have been running on Bonsai.2.8.0 with Bonsai.Harp.3.5.0

@NPM-Chris
Copy link
Author

I have recreated this issue with Bonsai.2.8.0 and Bonsai.Harp.3.4.0. I have also found a way to make it more reproducible:

  1. Have two workflows saved to different folders, one is empty, and one only as the "Device" node with the "PortName" property specified.
  2. Open the empty workflow from the file explorer, then do something to the workflow so you can press CTRL + S to save it (i.e. insert a node and delete it).
  3. Click File -> Open and open the workflow containing the "Device" node with the "PortName" property specified.

Following these three steps have consistently caused the error mentioned earlier to populate the command window followed by all Bonsai windows closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant