You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While not documented in the coremidi crate, PacketBuffer has an intrinsic size limit based on a poorly documented and handled size limit in Apple's CoreMIDI MIDIPacketList and MIDIPacket structures. The size limit is a bit less than 65536. (Exact value isn't documented!)
MidiOutputConnection's send() takes whatever data is passed in and passes it directly to PacketBuffer. If the data is big (think 80k sysex messages) - then PacketBuffer creates a corrupted buffer, which when sent causes a hard crash.
If the semantics of send() are that it will send what ever it is handed... then it needs to break larger messages up into chunks, and send the one after another.
If the semantics of send() are that it wants to inherit the limits of PacketBuffer, then it should document, and perhaps enforce that constraint.
How did I find this? I'm sending 80k sysexs (to control a synth) from a WebMIDI app.... and in Firefox on Mac it crashes the browser completely and instantly! I don't know who to blame for the crash... but the 80k byte array gets passed:
Thanks for reporting the bug! The underlying reason is that the coremidi crate is unsound. The macOS implementation in midir uses the safe API from coremidi, which is not supposed to crash (it may panic, though ... not sure if that would also crash the Firefox browser). But this should be fixed in coremidi to return a Result::Err in such a case, which would then be forwarded by midir.
You're probably right that the solution of splitting such a large sysex into multiple messages could and should be done in midir, to make the sending of such large messages consistently work on all platforms.
Seems like inspiration could be taken from Chromium. A PR is welcome :-)
While not documented in the coremidi crate, PacketBuffer has an intrinsic size limit based on a poorly documented and handled size limit in Apple's CoreMIDI MIDIPacketList and MIDIPacket structures. The size limit is a bit less than 65536. (Exact value isn't documented!)
MidiOutputConnection's send() takes whatever data is passed in and passes it directly to PacketBuffer. If the data is big (think 80k sysex messages) - then PacketBuffer creates a corrupted buffer, which when sent causes a hard crash.
If the semantics of send() are that it will send what ever it is handed... then it needs to break larger messages up into chunks, and send the one after another.
If the semantics of send() are that it wants to inherit the limits of PacketBuffer, then it should document, and perhaps enforce that constraint.
How did I find this? I'm sending 80k sysexs (to control a synth) from a WebMIDI app.... and in Firefox on Mac it crashes the browser completely and instantly! I don't know who to blame for the crash... but the 80k byte array gets passed:
The text was updated successfully, but these errors were encountered: