Skip to content

Commit d72193f

Browse files
committed
Strip - fixed potential race-condition in onReset
1 parent d5a115d commit d72193f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/modules/strip/Strip.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,18 @@ struct StripModule : StripModuleBase, StripIdFixModule {
111111
void onReset(const ResetEvent& e) override {
112112
randomParamsOnly = false;
113113
presetLoadReplace = false;
114-
// Initialize snapshot to empty set so UI can read safely immediately
115-
excludedParams.clear();
116-
excludedParamsPtr.store({});
114+
// excludedParams and its engine->UI snapshot (excludedParamsPtr) are owned by
115+
// the engine thread. onReset may run on the UI/main thread (e.g. "Initialize"
116+
// from the context menu), so clearing them inline would make both the UI thread
117+
// and the engine thread write the same SpscLatestValue, breaking its strict
118+
// single-writer contract and corrupting the heap. Defer the clear to the engine
119+
// thread via the same task mechanism used by every other exclude mutation.
120+
// (SpscLatestValue default-constructs to an empty set, so UI reads stay safe
121+
// until the task runs on the next process() tick.)
122+
groupExcludeClearRequest();
123+
// excludedParamsPtrUi is the UI->engine channel; its writer is the UI/main
124+
// thread, so resetting it here is safe and prevents a stale snapshot from
125+
// being reloaded later.
117126
excludedParamsPtrUi.store({});
118127
Module::onReset(e);
119128
}

0 commit comments

Comments
 (0)