-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8074211: javax.sound.midi: Error with send System Exclusive messages of different length #16399
Conversation
👋 Welcome back AlecJY! A progress list of the required criteria for merging this PR into |
/issue add 8250667 |
@AlecJY |
Webrevs
|
Mailing list message from Florian Bomers on client-libs-dev: Interesting! For drivers that send Sys-Ex asynchronously, the dwBufferLength field Florian On 27.10.2023 13:51, null wrote: -- |
I think the java code in the description can be added as a testcase, even if it works fine before the patch, it is useful that the affected code will be triggered. |
@AlecJY Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
Thanks for the suggestions from Florian Bomers and @mrserb. I’ve added a new structure to record the actual buffer length. Therefore the actual buffer length doesn’t need to write back to dwBufferLength. Additionally, The example code is added as a testcase. Please let me know if there are any further improvements needed. |
This seems to be documented by Microsoft only in the most obscure fashion. If you look at the doc for midiOutPrepareHeader So no mention of dwBytesRecorded. WAVEHDR is a very similar struct to MIDIHDR and if you look at this WAVEHDR doc it says https://learn.microsoft.com/en-us/previous-versions/dd743837(v=vs.85)
So I infer the same is true for MIDI Therefore dwBytesRecorded is only used for input and dwBufferLength is what's important for output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this change through our CI testing system and it all looks good.
@AlecJY This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 27 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@prrace) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
/sponsor |
Going to push as commit e47cf61.
Your commit was automatically rebased without conflicts. |
JVM attempts to reuse the buffer for sending MIDI out data when the buffer size is enough. It use
dwBytesRecorded
inMIDIHDR
structure to indicate the actual size of the data. However,midiOutLongMsg()
ignoresdwBytesRecorded
, although it did not mentioned in the documentation. I've tested on Windows 7, 10 and 11. All of them have the same behavior.The bug cannot be easily reproduced because some MIDI drivers filter out any malformed MIDI data. The example code below create a special case to make sure all MIDI data are legally when the bug is triggered.
The expected messages received should be the following three messages
But acually four messages was received with the second message repeated twice.
To resolve the issue, I add a new variable to backup the actual buffer size and set
dwBufferLength
ofMIDIHDR
structure to the size of MIDI data. After callingmidiOutLongMsg()
, I restore the original buffer size if the buffer hasn't been freed due to an error.It seems that the patch may also resolve JDK-8250667. The extra bytes in the second sysex message is the same issue as JDK-8074211. I didn't figure out how the scrambled data generated in the third sysex message, but all the messages are correct after applying the patch.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16399/head:pull/16399
$ git checkout pull/16399
Update a local copy of the PR:
$ git checkout pull/16399
$ git pull https://git.openjdk.org/jdk.git pull/16399/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16399
View PR using the GUI difftool:
$ git pr show -t 16399
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16399.diff
Webrev
Link to Webrev Comment