question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cursor(Stream) constructor has "short read", doesn't check return value from Stream.Read()

See original GitHub issue

This 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 Cursors 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)

cc @bitcrazed @filipnavara @RussKie

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
bitcrazedcommented, Mar 6, 2022

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.

1reaction
AngeloCrestacommented, Mar 23, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cursor(Stream) bugs · Issue #3492 · dotnet/winforms
rickbrew mentioned this issue on Mar 4, 2022. Cursor(Stream) constructor has "short read", doesn't check return value from Stream.Read() # ...
Read more >
java - Specifying cursor options when returning a Stream in ...
Your error is occurring because you are processing the stream too slowly, so the cursor is timing out before you get to the...
Read more >
Not able to read data from cursor_stream.read()
Hi, I have a simple piece of code that uses the .stream() method of a query result cursor and tries to iterate over...
Read more >
How to get query results as a Stream with Hibernate 5.2
In this post, I want to show you a small addition to the Query interface. The new stream() method allows you to process...
Read more >
The 10 Most Common Mistakes in C# Programming
Don't fall into one of these C# programming mistakes that even savvy developers can find problematic. Read on to see all 10.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found