max: fix crash on DSP start with fixed/wider output buses#127
Merged
Conversation
The Max audio object's `multichanneloutputs` handler returned the runtime *input* channel count, but dsp() allocates and the object writes max(output_channels, input_chans) output channels. For an effect with a fixed output bus (e.g. fixed_audio_bus<double, 2>) fed a mono signal, Max was told to allocate 1 output channel while the object unconditionally writes channel 1 too -> out-of-bounds write in perform() -> hard crash the moment DSP starts. Report the same channel count dsp() uses: max(output_channels, max(input_channels, runtime_input_count)). Now a mono source into a fixed-stereo effect gets 2 output channels allocated and runs cleanly. Verified in Max 8: cycle~ -> oscr_Distortion (fixed_audio_bus<..,2> out) -> ezdac~ with DSP on no longer crashes (survives with an empty console; previously it crashed on the first perform call). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011s7huWR2wFsLFiMJPjx1z2
This was referenced Jul 1, 2026
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.
Bug
A Max audio external built from an object with a fixed output bus (e.g.
fixed_audio_bus<double, 2>) crashes the instant audio (DSP) starts when fed a mono source.Root cause
audio_processor'smultichanneloutputshandler reported the runtime input channel count:But
dsp()allocates — and the object writes —max(output_channels, input_chans)output channels. With a monocycle~→ the effect, Max was told to allocate 1 output channel, while the object'soperator()unconditionally writesoutputs.audio.channel(1, N)too → out-of-bounds write inperform()→ hard crash on the first DSP tick.Fix
Report the same count
dsp()uses:A mono source into a fixed-stereo effect now gets 2 output channels allocated, matching what the object writes.
Verification
Built the
oscr_Distortionexternal (Tutorial/Distortion,fixed_audio_bus<double, 2>output) and ran it in Max 8:cycle~ 220→oscr_Distortion→ezdac~with DSP auto-started vialoadbang → [; dsp 1(. Before: crash on DSP start. After: runs cleanly for 30s+, empty Max console, no crash dialog.Found while GUI-verifying the auto-generated help patches (unrelated PR #126); this is a pre-existing Max-binding bug.
🤖 Generated with Claude Code