Skip to content

Fix AudioDeviceManager destructor race on midiCallbackLock#115

Merged
kunitoki merged 1 commit into
mainfrom
copilot/check-fix-from-juce-1669
Jun 9, 2026
Merged

Fix AudioDeviceManager destructor race on midiCallbackLock#115
kunitoki merged 1 commit into
mainfrom
copilot/check-fix-from-juce-1669

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

midiCallbackLock is declared after enabledMidiInputs in the header, so it's destroyed first. A live MIDI input callback can then access the already-destroyed CriticalSection, causing EXCEPTION_ACCESS_VIOLATION_WRITE in RtlEnterCriticalSection.

Change

  • yup_AudioDeviceManager.cpp: explicitly call enabledMidiInputs.clear() at the top of ~AudioDeviceManager(), ensuring all MIDI inputs are torn down while midiCallbackLock is still valid.
AudioDeviceManager::~AudioDeviceManager()
{
    enabledMidiInputs.clear();   // ← added; must happen before midiCallbackLock is destroyed
    currentAudioDevice.reset();
    defaultMidiOutput.reset();
}

Copilot AI changed the title Fix AudioDeviceManager destructor crash on shutdown (port of juce-framework/JUCE#1669) Fix AudioDeviceManager destructor race on midiCallbackLock (port of juce-framework/JUCE#1669) Jun 9, 2026
Copilot AI requested a review from kunitoki June 9, 2026 18:00
@kunitoki kunitoki marked this pull request as ready for review June 9, 2026 18:01
@kunitoki kunitoki changed the title Fix AudioDeviceManager destructor race on midiCallbackLock (port of juce-framework/JUCE#1669) Fix AudioDeviceManager destructor race on midiCallbackLock Jun 9, 2026
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.50%. Comparing base (1a531a6) to head (525547e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   78.49%   78.50%   +0.01%     
==========================================
  Files         605      605              
  Lines       60548    60549       +1     
==========================================
+ Hits        47525    47537      +12     
+ Misses      13023    13012      -11     
Files with missing lines Coverage Δ
..._audio_devices/audio_io/yup_AudioDeviceManager.cpp 72.03% <100.00%> (+0.04%) ⬆️

... and 6 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a572487...525547e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunitoki kunitoki merged commit b677dc8 into main Jun 9, 2026
40 checks passed
@kunitoki kunitoki deleted the copilot/check-fix-from-juce-1669 branch June 9, 2026 18:45
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.

2 participants