Skip to content

Fix PortRegistration race causing heap corruption on plugin removal#97

Open
sastraxi wants to merge 1 commit into
mod-audio:masterfrom
TreeFallSound:fix/effect-drain-midi
Open

Fix PortRegistration race causing heap corruption on plugin removal#97
sastraxi wants to merge 1 commit into
mod-audio:masterfrom
TreeFallSound:fix/effect-drain-midi

Conversation

@sastraxi

@sastraxi sastraxi commented Jul 5, 2026

Copy link
Copy Markdown

PortRegistration() enqueues POSTPONED_JACK_MIDI_CONNECT events on a JACK callback thread with no teardown guard. effects_remove() drains g_rtsafe_list in effects_remove_inner_pre(), then frees all plugin clients via lilv_instance_free()/dlclose()/jack_client_close(). Events arriving between the drain and those closes race against freed memory, corrupting the heap and causing SIGSEGV on the next dlclose().

Add a second splice-and-free drain immediately after the teardown loop in both effects_remove() and effects_remove_multi(), using the same pattern already present in effects_remove_inner_pre(). Closes #94.

PortRegistration() enqueues POSTPONED_JACK_MIDI_CONNECT events on a
JACK callback thread with no teardown guard. effects_remove() drains
g_rtsafe_list in effects_remove_inner_pre(), then frees all plugin
clients via lilv_instance_free()/dlclose()/jack_client_close(). Events
arriving between the drain and those closes race against freed memory,
corrupting the heap and causing SIGSEGV on the next dlclose().

Add a second splice-and-free drain immediately after the teardown loop
in both effects_remove() and effects_remove_multi(), using the same
pattern already present in effects_remove_inner_pre(). Closes mod-audio#94.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

PortRegistration race leads to heap corruption during effects_remove

1 participant