[cairo] PATCHES for FPERR crashes during spline rendering

Owen Taylor otaylor at redhat.com
Mon Aug 22 13:01:29 PDT 2005


On Wed, 2005-06-22 at 20:53 -0400, John Ellson wrote:
> Here are two patches that I've found necessary to avoid SIGFPEs when 
> rendering curves
> for graphviz.    I've tried and failed to generate simple test cases 
> that trigger the faults, but with
> graphviz they happen almost immediately.   With the patches applied
> I get no faults in cairo for all our 50 or so test graphs.
> 
> The problem in cairo-matrix.c is with attempts to take sqrt of negative 
> values.  The fix clamps the result to zero.

The eigenvalue code in cairo-matrix.c will go away with Bertram's 
outstanding patches, so that shouldn't be a problem any more.

> The problem in cairo-fixed.c is from overflows during double->fixed 
> conversion.  The fix clamps the result to max value
> of the correct sign.

 cairo_fixed_t
 _cairo_fixed_from_double (double d)
 {
+    if (d >= 32767)
+       return (cairo_fixed_t)(32767 * 65536);
+    if (d <= -32767)
+       return (cairo_fixed_t)(-32767 * 65536);
     return (cairo_fixed_t) (d * 65536);
 }

Hmm, that's sort of expensive for such a common operation. And it seems
to me that when there is truncation here it indicates a real problem -
just the sort of problem that you'd want to find if you turn on this
sort of FP error. There may be some cases where truncation is "gentle",
but if you say truncate on an out-of-bounds point, the result can 
be dramatically different.

Regards,
						Owen



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050822/528e59aa/attachment-0001.pgp


More information about the cairo mailing list