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

[BUG] Sending messages without monitoring causes Green Screen with the USB MIDI 2.0 driver #307

Closed
m-komo opened this issue Apr 11, 2024 · 13 comments
Assignees
Labels
area-service-or-api 🖥️ Related to the Windows Service, core API, abstractions, etc. area-usb-driver 💻 Related to the USB MIDI 2.0 driver bug 🐞 Something isn't working critical ‼️ Critical to be fixed/implemented before next major release driver-august-2024-fixed Fixed in the August 2024 update to the USB MIDI 2 driver

Comments

@m-komo
Copy link
Collaborator

m-komo commented Apr 11, 2024

Describe the bug
Sending a lots of messages without monitoring causes Green Screen.
This issue only occurs if the device is running with the USB MIDI 2.0 driver (UsbMidi2.sys)

To Reproduce

  1. Update ProtoZOA with the attached firmware.
  2. Attach ProtoZOA to PC and update the driver to the USB MIDI 2.0 driver (UsbMidi2.sys).
  3. Open console and make sure there is no monitoring command (midi endpoint monitor) running.
  4. Run "midi endpoint send-message 0x40123456 0x00000000 -p 0 -c 125000 -i".
  5. Choose "ZOA-216" as an endpoint.
  6. Repeat step 4 to 5 several times.

Green Screen occurs.
I faced two types of Green Screen, "ATTEMPTED_SWITCH_FROM_DPC" and "KERNEL_SECURITY_CHECK_FAILURE".

Expected behavior
No Green Screen.

Installer Name or Version

  • Service: Windows.MIDI.Services.Developer.Preview.5.x64.1.0.24066.2126.exe
  • Driver: Updated_USBMIDI2_10.0.1.4.zip

Desktop (please complete the following information):

  • OS: Windows 11
  • OS Build: 26100.1

Device information, if this is with an external MIDI device:

@m-komo m-komo added the bug 🐞 Something isn't working label Apr 11, 2024
@Psychlist1972 Psychlist1972 added area-usb-driver 💻 Related to the USB MIDI 2.0 driver area-service-or-api 🖥️ Related to the Windows Service, core API, abstractions, etc. needs-investigation 🔍 Needs to be investigated before considering or solving. labels Apr 11, 2024
@MusicMaker
Copy link

MusicMaker commented Apr 14, 2024

https://www.windowslatest.com/2024/04/06/windows-11-24h2-build-26100-causes-undocumented-issues-blocks-some-apps/
FYI 26001 is reported to be buggy with several GSODs.. I can't even do Windows update to it anymore ATM. (stuck at an older version which by itself is also a known issue and suggests a clean install)

@MusicMaker
Copy link

MusicMaker commented Apr 15, 2024

Finally installed 26100.1 (after using a network cable and several retires)

Loaded that FW in an off the shelf RP2040 board , assigned the midi preview 5 driver and ran that command many times. it sens the data, Cannot reproduce the GSOD.

@MusicMaker
Copy link

MusicMaker commented Apr 15, 2024

Got two crashes now of Windows 11. (auto reboots)... but not when running the command but with that RP2040 connected after running the commands. need further check if related. Now fully reproduceable. indeed an GSOD

@Psychlist1972
Copy link
Contributor

Thank you for the repro and the crash dump, @MusicMaker.

https://www.windowslatest.com/2024/04/06/windows-11-24h2-build-26100-causes-undocumented-issues-blocks-some-apps/ FYI 26001 is reported to be buggy with several GSODs.. I can't even do Windows update to it anymore ATM. (stuck at an older version which by itself is also a known issue and suggests a clean install)

If you want to get off the Canary train, I was told Dev channel has the ACX / USB updates in it now, so USB MIDI 2 will work on it.

@MusicMaker
Copy link

MusicMaker commented Apr 15, 2024

Indeed. noticed the Dev channel works too. Regress it with next canary build....

@Psychlist1972 Psychlist1972 added the critical ‼️ Critical to be fixed/implemented before next major release label Apr 16, 2024
@AmeNote-Michael
Copy link
Collaborator

Needs further investigation and analysis.

@garydan42 thinking about it, the act of midi endpoint send-message will put driver into "run" state which will process the USB IN buffer and into double buffer. As there is no monitor or application, nothing will be feeding from double buffer. In code, the reaction is to drop data but then request to handle existing data.

We should actually respond with discarding oldest data and then putting new data in buffer. What is the design pattern for this?

However, does not explain GSOD - just noting what we should be doing.

@Psychlist1972 Psychlist1972 added the dp6-fixed 🥳 Fixed/implemented in Developer Preview 6 label May 22, 2024
@Psychlist1972 Psychlist1972 moved this to 💻 Complete in Windows MIDI Services May 22, 2024
@AmeNote-Michael
Copy link
Collaborator

@garydan42 This issue is due to the "Run" state being set when a send-message occurs but nothing is reading from driver. If the device has data provided and the driver is in run state, driver will populate the double buffer stream for UMP IN with UMP data. If there is nothing reading from the UMP Data from that stream, it will eventually fill.

I suspect we should just drop old data - but what is design pattern here? How do I ensure I am not conflicting on memory with other software that may be accessing stream? Is it same as when dealing with buffer for write?

@garydan42
Copy link
Collaborator

garydan42 commented Jul 3, 2024 via email

@Psychlist1972 Psychlist1972 removed the dp6-fixed 🥳 Fixed/implemented in Developer Preview 6 label Jul 14, 2024
@m-komo
Copy link
Collaborator Author

m-komo commented Jul 18, 2024

I have confirmed that the issue has been solved.

  • Service: Windows.MIDI.Services.In-Box.Service.-.Developer.Preview.6.1.0.24194.2233-x64.exe
  • Driver: [interim preview build] 240713-USBMidi2-x86-TESTSIGNED.zip (DriverVer = 07/13/2024,23.1.50.504)
  • OS: Windows 11 24H2 (OS Build 26100.1150)

@MusicMaker
Copy link

MusicMaker commented Jul 18, 2024

That's not to say that the cross-process queue can't become full because messages are arriving faster than they can be processed or the callback blocks or hangs. The expectation is that the newest messages are dropped in that case,

This makes most sense, but could that not lead to a stall or a new reader process retrieving a lot of old messages ? another way could be to reset the queue when the queue overflows, but then nothing should be reading it, otherwise it could end up reading a non valid UMP message and it needs to handle to skip over corrupt data.

@AmeNote-Michael
Copy link
Collaborator

@garydan42 I am thinking that the correct response here should be that on processing a continuous reader data input, if it looks like another message could fill cross-process queue to full, should stop continuous reader - this should cause USB stack to start to queue and use its own flow control. Then some event (maybe reads from cross-process queue check to see if continuous reader needs to be restarted) would start the continuous reader once enough space exists for servicing a max size USB message.

This of course would take a bit of rework to driver - and should be made a feature request.

@AmeNote-Michael
Copy link
Collaborator

AmeNote-Michael commented Jul 20, 2024

@garydan42 @Psychlist1972 I feel that this original issue can be closed and that a new one indicating dropping USB data in large transfers should be created. Green screens no longer occurring I believe but fix may have created a new issue.

UPDATE: Issue #362 may be related, and no further issue needs to be added.

@Psychlist1972 Psychlist1972 added the driver-august-2024-fixed Fixed in the August 2024 update to the USB MIDI 2 driver label Jul 31, 2024
@Psychlist1972 Psychlist1972 removed the needs-investigation 🔍 Needs to be investigated before considering or solving. label Aug 16, 2024
@Psychlist1972
Copy link
Contributor

Closing as fixed in the August 2024 driver release. If you find it not to be when testing, will reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-service-or-api 🖥️ Related to the Windows Service, core API, abstractions, etc. area-usb-driver 💻 Related to the USB MIDI 2.0 driver bug 🐞 Something isn't working critical ‼️ Critical to be fixed/implemented before next major release driver-august-2024-fixed Fixed in the August 2024 update to the USB MIDI 2 driver
Projects
Status: 💻 Complete
Development

No branches or pull requests

5 participants