ADDITIONAL SYSTEM INFORMATION :
i7-12700H / Windows 11 22H2 / OpenJDK 22-ea+20
i7-12700H / OpenSUSE Tumbleweed / OpenJDK 22-ea+20
A DESCRIPTION OF THE PROBLEM :
SysexMessage allows splitting a sysex message into multiple SysexMessage. The first SysexMessage will start with 0xF0. Other continuing SysexMessage will start with 0xF7. A SysexMessage starting with 0xF0 can be send by javax.sound.midi.Receiver normally. However, attempting to send a SysexMessage starting with 0xF7 results in a JVM crash.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
First, make sure there is at least one MIDI output device provided by OS, such as "Microsoft GS Wavetable Synth" in Windows or the "snd_virmidi" kernel module in Linux.
Second, split a sysex message into at least two SysexMessage and send to the MIDI output device.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The MIDI device received the sysex message.
ACTUAL -
On Windows, JVM crashes without any error messages.
On Linux, JVM crashes with the following error message
free(): invalid pointer
Aborted (core dumped)
---------- BEGIN SOURCE ----------
import javax.sound.midi.*;
public class SysexTest {
public static void main(String[] args) {
var deviceInfos = MidiSystem.getMidiDeviceInfo();
for (var info : deviceInfos) {
try (MidiDevice device = MidiSystem.getMidiDevice(info)) {
if (device.getMaxReceivers() != 0) {
System.out.println("Open MIDI port: " + info.getName());
device.open();
Receiver receiver = device.getReceiver();
try {
// Send (F0 7D 01 02), (03 04), (05 06 F7) separately
receiver.send(new SysexMessage(new byte[]{(byte) 0xF0, 0x7D, 0x01, 0x02}, 4), -1);
receiver.send(new SysexMessage(new byte[]{(byte) 0xF7, 0x03, 0x04}, 3), -1);
receiver.send(new SysexMessage(new byte[]{(byte) 0xF7, 0x05, 0x06, (byte) 0xF7}, 4), -1);
System.out.println("All SysexMessage sent");
} catch (InvalidMidiDataException e) {
e.printStackTrace();
}
}
} catch (MidiUnavailableException e) {
e.printStackTrace();
}
}
}
}
---------- END SOURCE ----------
FREQUENCY : always