[cairo] Endless loop in _cairo_stroker_line_to_dashed()

Chris Wilson chris at chris-wilson.co.uk
Sun Jun 28 03:24:00 PDT 2009


On Sun, 2009-06-28 at 12:00 +0200, Hans Breuer wrote:
> The loop "while (remain)" is only left if 'remain' evaluates to exactly 
> zero, but in the given case it never gets closer than 5.3172935301562e-315.
> 
> Furher loop cycles don't modify that value anymore. 
> _cairo_stroker_add_sub_edge() adds no edge due to p1==p2 (in cairo fixed 
> oordinates). The patch below adds an additional check to leave the loop but 
> I'm uncertain if this is the right way to fix the issue.

Well I'm confused. If we exclude the possibility of precision-loss (it
uses doubles through out, though still that is no guarantee) then the
loop should always terminate, as it essentially does:
  while (remain) {
    step_length = MIN (remain, dash_remain);
    remain -= step_length;
    dash_remain -= step_length;
    if (dash_remain <= 0.) dash_remain=dashes[dash++];
  }

It would be good to have a test case for this bug. Have you managed to
replicate this whilst tracing? I think you will need to add
CAIRO_TRACE_FLUSH=1 to your environment to capture the last operation
before the infinite loop. (Or you can provide instructions on how I can
reproduce this bug myself using dia, and I'll create a test case.)
Thanks.
-ickle



More information about the cairo mailing list