Bug#940661: swh-plugins: analogueOsc produces NaN under some conditions (reloaded)

Frank Heckenbach f.heckenbach at fh-soft.de
Wed Sep 18 17:50:42 BST 2019


Package: swh-plugins
Version: 0.4.17-2
Severity: normal
Tags: upstream patch

The bug from
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781997
has reappeared!

The same test program as given there fails again, even though my
patch from then has been applied.

I suppose this is due to more aggressive optimizations by newer
compiler versions, in connection with the "-ffast-math" option.

In particular, my isnan() check doesn't work because "-ffast-math"
ignores NaNs (see https://stackoverflow.com/a/38981307).

So I tried a different fix now by checking for the problematic case
before NaN is produces. This seems to work for me.

This patch undoes my previous patch, so it's to be applied on top of
it.

It also fixes another instance of the problem (which my previous
patch didn't) that occurs when q is close to zero, i.e. when warm is
close to 0.999f (which is in the valid range!).

Though I wonder if "-ffast-math" should be used at all. As another
answer on the SO page linked above says: "No, you cannot safely use
-ffast-math except on code designed to be used with it. There are
all sorts of important constructs for which it generates completely
wrong results." I think edge cases like the one causing this problem
are exactly the kind of things one must watch out for when using
"-ffast-math", so I wonder if the code has actually been checked
carefully for "-ffast-math" compatibility. If not, it might be
worthwhile to sacrifice a few CPU cycles for correct results. Of
course, that's a bigger decision that I can't make in a bug fix, but
you may want to consider it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osc-nan-2.patch
Type: text/x-diff
Size: 871 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-multimedia-maintainers/attachments/20190918/339be028/attachment.patch>


More information about the pkg-multimedia-maintainers mailing list