Smoothing in ai soft support broken for NaN/inf values

Bug #1351332 reported by Ralph Lange
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Ralph Lange

Bug Description

The ai soft support contains the following code:

    if (!dbGetLink(&prec->inp, DBR_DOUBLE, &val, 0, 0)) {

        /* Apply smoothing algorithm */
        if (prec->smoo != 0.0 && prec->dpvt)
            prec->val = val * (1.00 - prec->smoo) + (prec->val * prec->smoo);
            prec->val = val;

        prec->udf = FALSE;

This breaks if the record's value is not finite (NaN/+inf/-inf), as the smoothing formula will never return a finite value, and the record is stuck with the NaN/+inf/-inf.

I would suggest to add one more condition to the inner if clause:

        /* Apply smoothing algorithm */
        if (prec->smoo != 0.0 && prec->dpvt && finite(prec->val))
            prec->val = val * (1.00 - prec->smoo) + (prec->val * prec->smoo);
            prec->val = val;

Tags: rec
Revision history for this message
Andrew Johnson (anj) wrote :

Thinking: While the previous value is NaN or ±Inf the new result will be the new value, but as soon as the previous value comes back to reality we start smoothing it again.

That looks right, please apply in 3.14 to both aiRecord.c and the devAiSoft.c device support which also implements this smoothing algorithm. I will merge the changes into 3.15 in due course.


Revision history for this message
Ralph Lange (ralph-lange) wrote :


In the record support, that code is part of the convert() routine that does the integer -> double conversion. As integers are finite, the problem does not appear .... unless you write to the VAL field directly through DB link or CA.

Changed in epics-base:
assignee: nobody → Ralph Lange (ralph-lange)
Changed in epics-base:
status: New → Fix Committed
Andrew Johnson (anj)
Changed in epics-base:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.