Cursor(Stream) constructor has "short read", doesn't check return value from Stream.Read()
See original GitHub issueThis is in .NET 6.0.2 but I don’t believe it’s new, it may be a very old issue.
Paint.NET 4.3.8 (latest public release) started crashing on the new Windows 11 Insider “Dev” build, 10.0.22567.0. It seems to be because of some Cursor
s that aren’t initializing correctly. My cursor files haven’t changed in quite some time, nor has the code for handling them. Now, I do believe this is a new bug in Win11, but there also seems to be a bug in WinForms.
Filip Navara @filipnavara on Twitter pointed out ( https://twitter.com/filipnavara/status/1499792311965913093?s=20&t=TUXrCwLBMiomnfPGQecZEw ) a “short read” in the Cursor(Stream)
constructor: https://github.com/dotnet/winforms/blob/04938f30a978874cebc88a399efbd0e89e1b4cb8/src/System.Windows.Forms/src/System/Windows/Forms/Cursor.cs#L87
So the data buffer is incompletely read into (because Stream.Read()
only promises to read more than 0 but less than or equal to length
bytes), initializing the handle fails, but the code keeps marching on
Here’s the exception and callstack that’s filling up my inbox, all from Win11 Insider Dev build 10.0.22567.0:
Exception details:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Disposed 'Cursor' can no longer be used.'.
at System.Windows.Forms.Cursor.get_Handle()
at Interop.User32.SetCursor(IHandle hCursor)
at System.Windows.Forms.Control.WmSetCursor(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (5 by maintainers)
Top GitHub Comments
Hi all. I can confirm that this is a bug in Win11 Insiders Dev release 10.0.22567.0, not in Paint.NET.
We have a fix and are working to get it released into a future Win11 Insiders Dev build ASAP.
Apologies for the inconvenience this issue has caused.
The external issue has been fixed in Version 10.0.22579.1 (Dev Channel), and, from release notes: Fixed an issue which was causing the mouse to be invisible in fields of certain apps, as well as some unexpected cursor related app crashes in recent flights. https://blogs.windows.com/windows-insider/2022/03/18/announcing-windows-11-insider-preview-build-22579/
EDIT: fixed the link