From 528244381a556c41ed4c189ad56d874bb593fbae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 2 Jul 2026 19:58:58 -0400 Subject: [PATCH] wrappers: always hand the effect zero-filled channels (never null) The process adapters (process/ and process_bus/, per-channel and poly) already had storage to point missing channels at silent scratch buffers, but it was gated behind a commented-out AVND_ENABLE_SAFE_BUFFER_STORAGE, so by default a host supplying fewer channels than the object declares left bus.channel = nullptr -- any effect that dereferences its channel then crashes. That null path is a core-invariant violation: an effect must always receive valid, zero-filled channel buffers. Enable the safe buffer storage by default (opt out with -DAVND_ENABLE_SAFE_BUFFER_STORAGE=0). process_bus/base.hpp includes process/base.hpp, so this one definition covers every backend. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_011s7huWR2wFsLFiMJPjx1z2 --- include/avnd/wrappers/process/base.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/avnd/wrappers/process/base.hpp b/include/avnd/wrappers/process/base.hpp index 805023c7..496112d6 100644 --- a/include/avnd/wrappers/process/base.hpp +++ b/include/avnd/wrappers/process/base.hpp @@ -17,7 +17,16 @@ #include #include #include -// #define AVND_ENABLE_SAFE_BUFFER_STORAGE 1 + +// The effect must always receive valid, zero-filled channel buffers. When a host +// supplies fewer channels than the object declares (e.g. an unconnected input), +// the missing channels must point at silent scratch buffers -- otherwise the +// effect dereferences a null channel pointer and crashes. This is a core +// invariant, so it is on by default; define AVND_ENABLE_SAFE_BUFFER_STORAGE=0 +// before including to opt out. +#ifndef AVND_ENABLE_SAFE_BUFFER_STORAGE +#define AVND_ENABLE_SAFE_BUFFER_STORAGE 1 +#endif namespace avnd {