Skip to content

usb-midi-device crashes esp32-s3 when OUT USB packets sent at line rate #1162

Description

@projectgus

Splitting this issue out from #1158 where it was independently discovered by @agatti while investigating a related issue.

The issue can be reproduced by setting up a CPython program that transmits MIDI data to the device as quickly as possible. For example:

import rtmidi2
out = rtmidi2.MidiOut()
# Port 1 is 'Espressif Device:Espressif Device MIDI 1 24:0' in my case
out.open_port(1)
while True:
    out.send_pitchbend(0, 0)  # channel, pitch
    out.send_noteon(0, 48, 100)
    out.send_noteoff(0, 48)
    print(".", end="")

(Note that only the second two messages are currently processed by the MIDI device class, pitchbend messages are discarded.)

If running midi_example.py on the ESP32-S3, the exhibited behaviour is a few messages may be processed normally and then the handler fails with nonsense errors such as:

Traceback (most recent call last):
  File "usb/device/midi.py", line 168, in _on_rx
  File "usb/device/core.py", line 859, in pend_read
AttributeError: 'Buffer' object has no attribute '_b'
Traceback (most recent call last):
  File "usb/device/core.py", line 342, in _xfer_cb
  File "usb/device/midi.py", line 156, in _rx_cb
  File "usb/device/core.py", line 827, in finish_write
AttributeError: 'Buffer' object has no attribute '_b'

and/or possibly a hard crash.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions