safe addition of arguments to existing ugens

nathan-PB1wun9k+p9Wk0Htik3J/[email protected]
Newsgroups gmane.comp.audio.supercollider.devel
Message-ID <[email protected]>
hi all,

in https://github.com/supercollider/supercollider/issues/2363, we 
learned the hard way that it's currently unsafe to introduce new 
arguments to ugens on the server. suppose ugen X takes a constant six 
arguments, and we add a seventh argument. we immediately update the 
sclang code so that it submits the correct number of inputs, but some 
alternate clients may not have gotten the news yet.

so if a client submits a synthdef that instantiates ugen X with only six 
arguments, the Unit is instantiated with unit->mNumInputs == 6, but the 
plugin code tries to read from the input wire buffer unit->mInBuf[6] (or 
IN(6)). the result is a read from garbage memory.

i thought of a very simple workaround for this -- in the Ctor code, a 
ugen can look at its own unit->mNumInputs and correctly handle edge 
cases. in the case of backward-compatible addition of arguments, this 
would mean that the new argument is optional and the plugin is smart 
enough to supply a default.

in general, the situation with unit->mNumInputs/unit->mInBuf and 
unit->mNumOutputs/unit->mOutBuf is fragile to malformed synthdefs. there 
is no guarantee that the number of inputs and number of outputs are 
consistent with what the plugin code actually accesses. could something 
be done to make this more robust on the server end?


nathan

_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.