[PD] What exactly is a "stack overflow" ?

IOhannes m zmoelnig zmoelnig at iem.at
Mon Dec 17 22:23:11 CET 2007

i put this back to the pd-list.
i guess (and hope) it was only by accident to you answered me in private.

Andy Farnell wrote:
> On Mon, 17 Dec 2007 21:08:05 +0100
> IOhannes m zmoelnig <zmoelnig at iem.at> wrote:
>> Andy Farnell wrote:
>>> On Mon, 17 Dec 2007 20:08:20 +0100
>>> Derek Holzer <derek at umatic.nl> wrote:
>>>> Sending a "bang" message to the [until] object, created without an 
>>>> argument saying how many times the bang should be done, will give 
>>>> roughly the same effect--
>>> If only!
>>> Objects that overflow the stack cause an exception, most of which trap
>>> nicely and you get a gentle report not to do that again.
>>> Sending an unqualified  bang to [until] will have you reaching for power
>>> switch because it enters a very tight loop with no exit condition and no
>>> hope of even seeing a SIGINT.
>>> I know we like to pretend this is "feature", but isn't it time to treat it
>>> as a bug?
>> so what is the behaviour you would like to see?
>> only allow fixed sized loops?
>> stop iterating after a maximum 10 bangs?
>> use [del 0] inbetween to make the loop interruptible?
> None of the above. Behaviour should be normal but if it's instantiated
> without arguments then bangs are ignored and only positive (I just saw the
> bug report for negatives) numbers are processed. Any finite number of
> iterations is the users concern, having bang mean loop infinitely seems
> wrong. 

but a [bang(--[until] is not meant to loop infinitely.
it loops until a certain condition is reached.

what you are asking for is a [for] object ("for" is _usually_ used for 
looping through a fixed number of iterations)
[until] corresponds to "while" and (tada!) "until" loops, which 
_usually_ are used to iterate a to-be-determined-number times.

so, probably you should just write an abstraction "for.pd":

[int $1]
[max 0]

and use that instead of [until].
you should be saved from any trouble you are experiencing so far.

(luckily it is like that: with [until] you can easily write [for]; it 
would be more difficult to do it the other way round; that is why i 
prefer it like it is)

>> btw, Pd does not freeze for me. while i am typing this email, an 
>> infinite [until] is eating most of my CPU power (but not all).
>> now i did send it a SIGINT and this freed my CPU.
> Now that's news to me. I've never been able to free a machine
> from a locked up [until], but I guess it must be possible in theory
> with a powerful enough CPU.

i don't think it is related to the power of CPU (btw, i am using a 
[bnag(--[until] should take all the resources the OS will grant it.
(just like "while(1);" will take all the resources it can get)
if the OS gives is _all_ the resources of the CPU you have a freeze.
if the OS reserves some cycles for itself, then you will be able to stop 
  the process.

btw, SIGINT killed my Pd.


More information about the Pd-list mailing list