{"record":{"id":"76aca2d5838011a8","repo":"openjdk/jdk","slug":"s-d-internal-error-pendingmessagestatus-0x-x","errorCode":null,"errorMessage":"%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n","messagePattern":"(.+?): (.+?)->internal error: pendingMessageStatus=0x%X, pendingDataLength=(.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c","lineNumber":319,"sourceCode":"            }\n        } else {\n            if (byte < 0x80) {\n                // Not a status byte -- check our history.\n                if (handle->readingSysExData) {\n                    CFDataAppendBytes(handle->readingSysExData, &byte, 1);\n\n                } else if (pendingDataIndex < pendingDataLength) {\n                    pendingData[pendingDataIndex] = byte;\n                    pendingDataIndex++;\n\n                    if (pendingDataIndex == pendingDataLength) {\n                        // This message is now done -- do the final processing.\n                        if (pendingDataLength == 2) {\n                            packedMsg = pendingMessageStatus | pendingData[0] << 8 | pendingData[1] << 16;\n                        } else if (pendingDataLength == 1) {\n                            packedMsg = pendingMessageStatus | pendingData[0] << 8;\n                        } else {\n                            fprintf(stderr, \"%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\\n\",\n                                    __FILE__, __LINE__, pendingMessageStatus, pendingDataLength);\n                            byteIsInvalid = TRUE;\n                        }\n                        pendingDataLength = 0;\n                    }\n                } else {\n                    // Skip this byte -- it is invalid.\n                    byteIsInvalid = TRUE;\n                }\n            } else {\n                if (handle->readingSysExData /* && (byte == 0xF7) */) {\n                    // We have reached the end of system exclusive message -- send it finally.\n                    const UInt8* bytes = CFDataGetBytePtr(handle->readingSysExData);\n                    CFIndex size = CFDataGetLength(handle->readingSysExData);\n                    MIDI_QueueAddLong(handle->h.queue,\n                                      (UBYTE*) bytes,\n                                      (UINT32) size,\n                                      0, // Don't care, windowish porting only.","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c#L301-L337","documentation":"An internal-invariant failure in the macOS MIDI input byte-stream parser (readBytesReceived / MIDI packet processing in MidiUtils.c). When a running-status or system-common message is fully accumulated, the code expects pendingDataLength to be exactly 1 or 2 data bytes; any other value means the state machine corrupted itself (status was set without a matching expected data length). It flags the byte invalid and skips it rather than crashing.","triggerScenarios":"A CoreMIDI device/driver delivers a malformed running-status sequence: a status byte whose expected data length was computed as 0 or >2 (e.g. an undefined 0xF4/0xF5 status becoming pending), followed by data bytes that complete the 'message'. Also triggered by drivers that fragment packets in ways that leave stale pendingMessageStatus from a prior message.","commonSituations":"Misbehaving or non-standard MIDI hardware (cheap USB-MIDI cables, class-compliant devices with buggy firmware); virtual MIDI ports (IAC, loopMIDI-style apps) fed hand-crafted byte streams; aggressive SysEx interleaving with running status. Rarely if ever caused by correct Java code — it is a driver/data problem surfaced by the JDK parser.","solutions":["Reproduce with the same device on another machine/OS to confirm the device or its driver emits the malformed stream","Update or replace the MIDI interface driver/firmware; test with a known-good device such as a mainstream USB keyboard","If using a virtual port, validate the bytes you inject: every status byte must be followed by exactly its protocol data length","Filter the device with MidiDevice.getTransmitter() only for devices you control, or ignore the stderr line — the parser skips the bad byte and recovers"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["If you feed virtual MIDI ports, emit protocol-conformant streams: correct data lengths per status byte","Test your devices with a MIDI monitor (e.g. MIDI Ox equivalent) before wiring them into Java","Treat the message as recoverable noise: the parser skips the byte and keeps going"],"tags":["midi","macos","native","parser","device-driver"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}