<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><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">74779</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>chris@chris-wilson.co.uk
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Segmentation fault when using a complex path for clip and stroke
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>cairo-bugs@cairographics.org
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>critical
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jlahd@iki.fi
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>1.12.16
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>image backend
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>cairo
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=93749" name="attach_93749" title="Code to reproduce the crash">attachment 93749</a> <a href="attachment.cgi?id=93749&action=edit" title="Code to reproduce the crash">[details]</a></span>
Code to reproduce the crash

When a sufficiently complex path, consisting of multiple subpaths, is used both
for clip and for stroke, cairo sometimes crashes in a segmentation fault. The
crash seems to happen in the function active_edges, where in the innermost
do...while loop the "right" variable for some reason gets a NULL value:

Program received signal SIGSEGV, Segmentation fault.
active_edges (polygon=0x7fffffffd440, top=32768, left=0x6b9a80) at
/build/buildd/cairo-1.12.16/src/cairo-polygon-intersect.c:1235
1235    /build/buildd/cairo-1.12.16/src/cairo-polygon-intersect.c: No such file
or directory.
(gdb) where
#0  active_edges (polygon=0x7fffffffd440, top=32768, left=0x6b9a80) at
/build/buildd/cairo-1.12.16/src/cairo-polygon-intersect.c:1235
#1  intersection_sweep (polygon=0x7fffffffd440, num_events=<optimized out>,
start_events=<optimized out>)
    at /build/buildd/cairo-1.12.16/src/cairo-polygon-intersect.c:1271
#2  _cairo_polygon_intersect (a=a@entry=0x7fffffffd440,
winding_a=winding_a@entry=0, b=b@entry=0x7fffffffcff0, winding_b=<optimized
out>)
    at /build/buildd/cairo-1.12.16/src/cairo-polygon-intersect.c:1466
#3  0x00007ffff7b3812a in clip_and_composite_polygon
(compositor=compositor@entry=0x7ffff7dd8000 <spans.11982>,
extents=extents@entry=0x7fffffffd880,
    polygon=polygon@entry=0x7fffffffd440, fill_rule=CAIRO_FILL_RULE_WINDING,
antialias=antialias@entry=CAIRO_ANTIALIAS_DEFAULT)
    at /build/buildd/cairo-1.12.16/src/cairo-spans-compositor.c:937
#4  0x00007ffff7b38c77 in _cairo_spans_compositor_stroke
(_compositor=0x7ffff7dd8000 <spans.11982>, extents=0x7fffffffd880,
path=<optimized out>, style=0x7fffffffdc70,
    ctm=0x604c70, ctm_inverse=0x604ca0, tolerance=0,10000000000000001,
antialias=CAIRO_ANTIALIAS_DEFAULT)
    at /build/buildd/cairo-1.12.16/src/cairo-spans-compositor.c:1074
#5  0x00007ffff7af7974 in _cairo_compositor_stroke (compositor=0x7ffff7dd8000
<spans.11982>, surface=0x6049c0, op=CAIRO_OPERATOR_OVER, source=0x7fffffffdca0,
    path=0x604eb8, style=0x7fffffffdc70, ctm=0x604c70,
ctm_inverse=ctm_inverse@entry=0x604ca0, tolerance=0,10000000000000001,
    antialias=antialias@entry=CAIRO_ANTIALIAS_DEFAULT,
clip=clip@entry=0x6089f0) at
/build/buildd/cairo-1.12.16/src/cairo-compositor.c:157
#6  0x00007ffff7b07953 in _cairo_image_surface_stroke
(abstract_surface=<optimized out>, op=<optimized out>, source=<optimized out>,
path=<optimized out>,
    style=<optimized out>, ctm=<optimized out>, ctm_inverse=0x604ca0,
tolerance=<optimized out>, antialias=CAIRO_ANTIALIAS_DEFAULT, clip=0x6089f0)
    at /build/buildd/cairo-1.12.16/src/cairo-image-surface.c:961
#7  0x00007ffff7b3bd42 in _cairo_surface_stroke (surface=0x6049c0,
op=CAIRO_OPERATOR_OVER, source=0x7fffffffdca0, path=0x604eb8,
stroke_style=0x7fffffffdc70,
    ctm=0x604c70, ctm_inverse=0x604ca0, tolerance=0,10000000000000001,
antialias=CAIRO_ANTIALIAS_DEFAULT, clip=0x6089f0)
    at /build/buildd/cairo-1.12.16/src/cairo-surface.c:2210
#8  0x00007ffff7aff05f in _cairo_gstate_stroke (gstate=0x604b80,
path=path@entry=0x604eb8) at
/build/buildd/cairo-1.12.16/src/cairo-gstate.c:1185
#9  0x00007ffff7af9079 in _cairo_default_context_stroke (abstract_cr=0x604b50)
at /build/buildd/cairo-1.12.16/src/cairo-default-context.c:1013
#10 0x00007ffff7af2875 in INT_cairo_stroke (cr=0x604b50) at
/build/buildd/cairo-1.12.16/src/cairo.c:2146
#11 0x0000000000400b8f in main () at bug.c:28

Can be reproduced reliably with the attached code.</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>