[PD] [packOSC] reentrancy problem

IOhannes m zmoelnig zmoelnig at iem.at
Thu Nov 19 09:49:54 CET 2015

On 2015-11-18 21:31, Martin Peach wrote:
> So I think I got it, it's in the latest svn revision.
> I hope it didn't break something else, but [packOSC] can now send messages
> triggered by its own output.

i had a quick glance at the code (didn't even try it out), but it seems
you are mainly pushing the problem a little bit "back" rather than
solving it.
that is: the output of [packOSC] can trigger a *single* message that is
feed back (via the stack) to it's own input.
it is not possible to have that 2nd message trigger a feedback again.

i don't think it is valid to just dismiss the problem, simply because
you (or I, for that matter) don't have an actual use case at hand (roman
has come up with one that requires first-level recursion, though
probably not deep recursion)

anyhow, i think the problem shouldn't be too hard to solve.
afaics, the main issue is, that (for performance reasons) you use an
intermediate "OSC buffer" that is allocated on the heap (and which will
get overwritten in recursion).
the solution is obviously to use a stack allocated buffer.

to keep the performance of a heap allocated buffer, i would suggest to:
- use the original scheme for an "immediate" (non-recursive) message
- detect recursion, and if so, allocate buffers on the stack.

this will make sure that a simple use of [packOSC] will be as fast as
ever, while at the same time allowing "infinite" recursion (bound by the
environment, not by [packOSC]) - albeit users of recursion will have to
live with a small performance penalty.


ยน see my other mail on [unpackOSC]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151119/2ff824ce/attachment.sig>

More information about the Pd-list mailing list