Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions engine/core/DynamicChannelFxLeaseBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ class DynamicChannelFxLeaseBank final {
owner->latencySamples>armix::dsp::StereoLatencyDelay::maximumSamples ||
owner->latencyChanged.load(std::memory_order_acquire))
return Fault::uncompensatedLatency;
// A cloned/restored processor may have a different pointer
// but reuse another plugin's durable instance token. Reject it
// BEFORE publishing a graph: FX MOVE, bypass, editor and
// .smix restoration all identify leases by this opaque token.
// This comparison and all JUCE strings stay on CONTROL only.
if(owner->instanceId.isEmpty())return Fault::emptyLease;
for(const auto& existing:candidate.rows_)
for(std::size_t k=0;k<existing.count;++k)
if(existing.owners[k].get()==owner.get())
if(existing.owners[k].get()==owner.get() ||
existing.owners[k]->instanceId==owner->instanceId)
return Fault::duplicateInstance;
for(std::size_t k=0;k<i;++k)
if(row.owners[k].get()==owner.get())
if(row.owners[k].get()==owner.get() ||
row.owners[k]->instanceId==owner->instanceId)
return Fault::duplicateInstance;
row.owners[i]=owner; // owner reference acquired OFF realtime
row.raw[i]=owner.get();
Expand Down
19 changes: 19 additions & 0 deletions tests/live_channel_fx_graph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ static void verifyUniversalChannelIdFxLeaseAndLivePcm() {
alias[1].inserts=first.inserts; // same native processor twice
assert(Bank::prepare(epoch,2,alias,blocked)==Bank::Fault::duplicateInstance);
assert(blocked.lanes()==0);
// Distinct native processors can still carry the SAME restored instance
// identity. Pointer-only guards miss this and allow the UI/editor to
// confuse two owners even if the accepted snapshot later rejects them.
auto collidingProcessor=std::make_unique<GainFx>(1.125f);
collidingProcessor->prepareToPlay(48000.,64);
const auto restoredId=first.inserts[0]->instanceId;
auto sameTokenDifferentOwner=std::make_shared<LiveChannelFxGraph::FxInstance>(
std::move(collidingProcessor),"collision-fixture","Collision fixture",64,
restoredId);
assert(sameTokenDifferentOwner.get()!=first.inserts[0].get());
alias[1].inserts={sameTokenDifferentOwner};
assert(Bank::prepare(epoch,2,alias,blocked)==Bank::Fault::duplicateInstance);
assert(blocked.lanes()==0);
Bank::Assignment sameChannel=first;
sameChannel.inserts.push_back(sameTokenDifferentOwner);
assert(Bank::prepare(epoch,2,std::span(&sameChannel,1),blocked)==
Bank::Fault::duplicateInstance);
assert(blocked.lanes()==0 && bank.insertCount(ch1)==1 &&
bank.insertCount(ch11)==1); // previous accepted graph untouched
// A fixed-latency VST lease is admitted; the PCM publisher consumes its
// exact inventory to prepare fan-in compensation before publication.
auto latentProcessor=std::make_unique<GainFx>(1.5f);
Expand Down
Loading