<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Segmentation fault when using a complex path for clip and stroke"
href="https://bugs.freedesktop.org/show_bug.cgi?id=74779#c7">Comment # 7</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Segmentation fault when using a complex path for clip and stroke"
href="https://bugs.freedesktop.org/show_bug.cgi?id=74779">bug 74779</a>
from <span class="vcard"><a class="email" href="mailto:sixtysix@inwind.it" title="Massimo <sixtysix@inwind.it>"> <span class="fn">Massimo</span></a>
</span></b>
<pre>Created <span class=""><a href="attachment.cgi?id=104274" name="attach_104274" title="patch to add an assert to verify an assumption">attachment 104274</a> <a href="attachment.cgi?id=104274&action=edit" title="patch to add an assert to verify an assumption">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=74779&attachment=104274'>[review]</a>
patch to add an assert to verify an assumption
Judging from the comment and the code at (where 'exactness' is used):
<a href="http://cgit.freedesktop.org/cairo/tree/src/cairo-polygon-intersect.c?id=7e856071a27b06a6ae35b6445635da9276975c69#n665">http://cgit.freedesktop.org/cairo/tree/src/cairo-polygon-intersect.c?id=7e856071a27b06a6ae35b6445635da9276975c69#n665</a>
it seems you want to compute the ordinate of an intersection rounded
toward -oo with the unused remainder non-negative.
adding an assert to verify this happens (as in the attached patch)
num = q * den + r
-> r = num - q * den
-> r >= 0
-> num >= q * den
it is evident from its failure when running the 'creduced' test case
intersect_lines: Assertion `(!((det64x32_128 (a_det, dx1, b_det, dx2)) <
(((int128_t) (qr.quo) * (den_det)))))' failed.
that when the computed remainder is not zero not always a > b
In case comments are old and misleading and you want to round to the nearest
integer I suspect the code computing the ordinate is anyway wrong:
for example when
<a href="http://cgit.freedesktop.org/cairo/tree/src/cairo-polygon-intersect.c?id=7e856071a27b06a6ae35b6445635da9276975c69#n608">http://cgit.freedesktop.org/cairo/tree/src/cairo-polygon-intersect.c?id=7e856071a27b06a6ae35b6445635da9276975c69#n608</a>
den64x32 = 16
den_det = -5
16 / -5 = -3.2
qr initially is {-3, 1} because 16 == -3 * -5 + 1
but den_det and qr.rem have different signs so qr.rem is
negated and doubled -> qr = { -3, -2 }
because now qr.rem >= den_det (-2 >= -5) qr.quo is decremented
to -4, which is not the nearest integer approximating -3.2
~</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>