[PD-dev] Whose fault is this crash? (nan and inf)

Kjetil Matheussen k.s.matheussen at gmail.com
Tue Sep 10 10:21:11 CEST 2013


This patch sometimes crashes PD:

[0.0000000000000000000000000000000001 (
|
[expr 1/$f1]
|
[env~]
|
[vd~ buffer 100]

[delwrite~ buffer]

The output of expr is inf.
The output of env~ is nan

vd~ doesn't always handle nan, and crashes.

A fix for vd~ can look like this:

--- a/pure-data/src/d_delay.c
+++ b/pure-data/src/d_delay.c
@@ -271,7 +271,11 @@ static t_int *sigvd_perform(t_int *w)
     t_sample zerodel = x->x_zerodel;
     while (n--)
     {
-        t_sample delsamps = x->x_sr * *in++ - zerodel, frac;
+      t_sample inval = *in++;
+      if(isnan(inval))
+        inval = 0.0f;
+
+        t_sample delsamps = x->x_sr * inval - zerodel, frac;


In Pd, should objects be able to handle (i.e. "not crash") when they get
input values of nan and inf, or should they instead make sure that
nan and inf never can be sent out of the objects, or both?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20130910/409e6827/attachment.htm>


More information about the Pd-dev mailing list