Skip to content

MIDI: release the nubs on a full stop instead of terminating them - #234

Open
Wolfcare wants to merge 1 commit into
mrmidi:mainfrom
Wolfcare:fix/midi-release-nubs-on-stop
Open

Wolfcare wants to merge 1 commit into
mrmidi:mainfrom
Wolfcare:fix/midi-release-nubs-on-stop

Conversation

@Wolfcare

Copy link
Copy Markdown

Problem and change

Unplugging the FireWire adapter while a MIDI endpoint is published aborts the dext.
ServiceContext::Reset(Full) calls MidiNubPublisher::TerminateAll(), which calls
Terminate() on nubs the kernel has already terminated with ASFWDriver's other
client services. DriverKit then asserts:

DriverKit  __assert_rtn
DriverKit  OSMetaClassBase::QueueForObject(unsigned long long)
DriverKit  IOService::Terminate(...)
net.asfw.driver  ASFW::Midi::MidiNubPublisher::TerminateNub(unsigned long long)
net.asfw.driver  ASFW::Midi::MidiNubPublisher::TerminateAll()
net.asfw.driver  ServiceContext::Reset(ServiceContext::ResetMode)
net.asfw.driver  ReleaseQuiescedRuntime(...)
net.asfw.driver  ASFWDriver::RequestRuntimeQuiesce(unsigned int)

SBP2NubPublisher::Shutdown already documents the same abort for SBP-2 nubs, and
handles it by dropping its bookkeeping. This change does the same for MIDI on a
full reset (MidiNubPublisher::ReleaseAll). A suspend reset still calls
TerminateAll, because the nubs are live then and wake publishes new ones.

Prior discussion

None. It's a crash fix that follows the existing SBP-2 pattern.

Architecture and scope

Midi/Core/MidiNubPublisher and Service/DriverContext.cpp. Applies to any family
that publishes MIDI nubs (DICE today; MOTU with the MOTU MIDI work).

Testing and evidence

  • New unit test MidiNubPublisherTests.ReleaseAllForgetsWithoutTerminating; full C++ suite passes (3,917 tests on this branch).
  • Hardware: MacBook Air M2, macOS 26.7.1, Apple Thunderbolt to FireWire Adapter, MOTU UltraLite mk3 with MIDI ports published.
    • Before: adapter unplug crashed the dext twice in a row (17:42 and 18:58).
    • After: releasing endpoint=... during shutdown is logged, no crash report, and MIDI is republished after replug.
  • Not tested: sleep/wake. The suspend path is unchanged.
  • Not tested: a DICE device with MIDI.

Regression risks

On a full stop the nubs are no longer explicitly terminated. That relies on the
kernel terminating them with the driver, the same assumption the SBP-2 publisher
already makes.

Unplugging the Thunderbolt-to-FireWire adapter with a MIDI endpoint
published aborted the dext: ServiceContext::Reset called Terminate() on the
MIDI nubs, which the kernel had already terminated with ASFWDriver's other
client services, and DriverKit asserted in OSMetaClassBase::QueueForObject
(reproduced twice on an UltraLite mk3, 2026-10-28). SBP2NubPublisher::Shutdown
records the same abort for SBP-2 nubs and only drops its bookkeeping.

MidiNubPublisher::ReleaseAll now does the same for a full reset. A reset
for suspend still terminates the nubs, which are live then and replaced on
wake. Verified on hardware: adapter unplug and replug, no crash report, MIDI
republished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant