Conversation
mpv <= 0.41 registers hotplug_cb against kAudioObjectSystemObject with a struct ao * as the listener context whenever audio-device-list is read. CoreAudio may still have a queued notification after the ao is freed, and the delivered callback dereferences ao->log with no validity check, crashing in mp_msg_va (mpv-player/mpv#18274). On macOS, mpv_audio_devices now enumerates output devices through the CoreAudio HAL directly — no listener is ever registered for enumeration. The produced names (coreaudio/<DeviceUID>) match ca_get_device_list, so audio-device property values stay compatible. Linux/Windows keep the previous behavior (live session, then the long-lived probe context). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Harbor 0.9.21 crashes with
SIGSEGVon macOS when a CoreAudio device-change notification races mpv's audio hotplug teardown. Crash signature (thread onHALC_ProxyNotification Call Listener Queue):hotplug_cb(audio/out/ao_coreaudio.c) receives astruct ao *as its listener context and immediately callsMP_VERBOSE(ao, "Handling potential hotplug event...")→mp_msg(ao->log, ...)aowas already freed while the notification was still queued (AudioObjectRemovePropertyListenerdoes not drain in-flight callbacks),ao->logreads 0 andmp_msg_vadereferences address0x0Reading
audio-device-listmakes libmpv register that listener — on a throwawayMpv, on the live session, and via probe AOs insideao_hotplug_get_device_list. Every one of those frees is a race window whenever a Bluetooth/HDMI/dock device event is delivered.Approach
On macOS,
mpv_audio_devicesno longer readsaudio-device-listat all. Newaudio_devices_mac.rsenumerates output devices through the CoreAudio HAL (AudioObjectGetPropertyData) — the same queries mpv'sca_get_device_listperforms, producing identical values:name = "coreaudio/<kAudioDevicePropertyDeviceUID>"description = kAudioObjectPropertyName(or"Unknown")kAudioDevicePropertyStreamConfigurationon the output scopeNames stay compatible with
mpv_set_property("audio-device", ...). Since the native path registers no listener, the enumeration-side crash surface is removed entirely. Linux/Windows keep the previous behavior (live session first, then the long-lived probe context added in #1177).Verification
cargo check— clean, no new warningscoreaudio/BuiltInSpeakerDevice, monitor outputs) with the same names mpv reports, and filters input-only devicespnpm run check/vp checkwas not runnable in this environment (no pnpm/node_modules); the change is Rust-onlyPlatform Impact
mpv_audio_devicesno longer touches libmpv for enumerationChecklist
vp checkfor the changed files. (Rust-only change;cargo checkclean.vptoolchain unavailable in this environment.)vp run typecheckafter TypeScript changes. (no TypeScript changes)Note: the playback AO still registers
hotplug_cbinside libmpv itself, so the same UAF remains possible on track/device changes until mpv fixes it upstream or we carry a patch on the bundledlibmpv.2.dylib. This PR removes the enumeration-triggered path, which is the one we control.Generated with Devin