Closed krevis closed 3 years ago
I'll get the code and start investigating. If this is a known bug, or if you have any pointers on where to start looking, I'd love to know more.
The crash happens here:
case 0x0: case 0x1: case 0x2: case 0x3:
case 0x4: case 0x5: case 0x6: case 0x7:
// DebugPrintf("sysex databyte %02X", c);
// data byte, presumably a sysex continuation
*dest[cableEndpoint]++ = c;
numToBeSent = srcend - src;
// sysex ends with 2 preceding data bytes or sysex continues, such that the
// sysex end message begins the packet as the cmd.
outPacketLen = (numToBeSent >= 3) ? 2 : numToBeSent - 1;
// DebugPrintf("outPacketLen = %d, numToBeSent = %d", outPacketLen, numToBeSent);
memcpy(dest[cableEndpoint], src, outPacketLen); // <------ CRASH HERE
memset(dest[cableEndpoint] + outPacketLen, 0, 2 - outPacketLen);
dest[cableEndpoint][2] = cableNibble | (outPacketLen + 1); // mark length and cable
dest[cableEndpoint] += (MIDIPACKETLEN - 1); // we advance by one packet length (4 bytes)
src += outPacketLen;
break;
This is the last byte of data to write (src == srcend
), so numToBeSent
is 0, outPacketLen
is -1
, and we try to memcpy too much.
(Thanks very much for the work on getting this driver running again. The MIDISport 2x2 was probably the first MIDI device I got working on OS X, 20 years ago, and it's great to save it from the electronics graveyard.)
When I send a large sysex message through the MIDISport 2x2, via
MIDISendSysex()
, the driver is consistently crashing here:Full crash log: MIDIServer_2021-10-16-213858_lite.crash.zip
Steps:
Expected: The whole 64 KB sysex message is transmitted, and nothing bad happens.
Actual: The MIDISport's Out LED goes on for less than a second, then off. There's a MIDIServer crash in Console. (SysEx Librarian also acts kind of erratically afterwards, triggered by the MIDIServer crash and restart, but that's my problem to solve.)
Something about this long sysex message seems to be triggering the crash. I didn’t see it with small sysex messages. Haven't worked out exactly how long is too long, yet.