[cairo] abort in postscript when printing

James Cloos cloos at jhcloos.com
Sun May 22 12:54:25 PDT 2011


I've noticed that some apps have been crashing of late whenever I try to
print.  Printing to PDF works find, only Postscript paths fail.

I run cairo master.  (And use my system cairo for apps such as 'zilla.)

An example backtrace (everything is compiled with -ggdb3, but only cairo
with -O0):

#0  0x00007f5fb470a935 in raise (sig=<value optimized out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007f5fb470bdb6 in abort () at abort.c:92
#2  0x00007f5fb4703555 in __assert_fail (
    assertion=0x7f5fb33c2b40 "status < CAIRO_STATUS_LAST_STATUS", file=<value optimized out>, 
    line=178, function=<value optimized out>) at assert.c:81
#3  0x00007f5fb33402cd in _cairo_surface_set_error (surface=0x7f5f94705090, status=104)
    at cairo-surface.c:178
#4  0x00007f5fb3343e74 in _cairo_surface_show_text_glyphs (surface=0x7f5f94705090, 
    op=CAIRO_OPERATOR_OVER, source=0x7f5f89d9e600, utf8=0x0, utf8_len=0, 
    glyphs=0x7f5f89d07740, num_glyphs=1, clusters=0x0, num_clusters=0, cluster_flags=0, 
    scaled_font=0x7f5f8fdc3800, clip=0x7fff0c674e20) at cairo-surface.c:2691
#5  0x00007f5fb334baca in _cairo_surface_wrapper_show_text_glyphs (wrapper=0x7fff0c674ed0, 
    op=CAIRO_OPERATOR_OVER, source=0x7f5f89d9e600, utf8=0x0, utf8_len=0, 
    glyphs=0x7f5f89d07740, num_glyphs=1, clusters=0x0, num_clusters=0, cluster_flags=0, 
    scaled_font=0x7f5f8fdc3800, clip=0x7f5f89d9e5f0) at cairo-surface-wrapper.c:613
#6  0x00007f5fb3333cba in _cairo_recording_surface_replay_internal (surface=0x7f5f9735a540, 
    surface_extents=0x0, target=0x7f5f94705090, type=CAIRO_RECORDING_CREATE_REGIONS, 
    region=CAIRO_RECORDING_REGION_ALL) at cairo-recording-surface.c:972
#7  0x00007f5fb3333e39 in _cairo_recording_surface_replay_and_create_regions (
    surface=0x7f5f9735a540, target=0x7f5f94705090) at cairo-recording-surface.c:1047
#8  0x00007f5fb331b70c in _paint_page (surface=0x7f5f92b12380) at cairo-paginated-surface.c:340
#9  0x00007f5fb331bb84 in _cairo_paginated_surface_show_page (abstract_surface=0x7f5f92b12380)
    at cairo-paginated-surface.c:494
#10 0x00007f5fb334385b in *INT_cairo_surface_show_page (surface=0x7f5f92b12380)
    at cairo-surface.c:2458
#11 0x00007f5fb63ddfcd in gfxPSSurface::EndPage (this=<value optimized out>)
    at gfxPSSurface.cpp:96
#12 0x00007f5fb5edb0d3 in nsThebesDeviceContext::EndPage (this=<value optimized out>)
    at nsThebesDeviceContext.cpp:1021
#13 0x00007f5fb552a375 in nsSimplePageSequenceFrame::DoPageEnd (this=0x7f5f8fdd57d0)
    at nsSimplePageSequence.cpp:655
#14 0x00007f5fb59d4178 in nsPrintEngine::PrintPage (this=0x7f5f949505e0, 
    aPO=<value optimized out>, aInRange=@0x7fff0c67510c) at nsPrintEngine.cpp:2553


The surface passed to _cairo_surface_set_error() looks like:

(gdb) p *surface
$2 = {backend = 0x7f5fb35f2020, device = 0x0, type = 4098, 
  content = CAIRO_CONTENT_COLOR_ALPHA, ref_count = {ref_count = 2}, 
  status = CAIRO_STATUS_SUCCESS, unique_id = 2950, finished = 0, is_clear = 0, 
  has_font_options = 0, owns_device = 0, user_data = {size = 0, num_elements = 0, 
    element_size = 24, elements = 0x0}, mime_data = {size = 0, num_elements = 0, 
    element_size = 24, elements = 0x0}, device_transform = {xx = 1, yx = 0, xy = 0, yy = 1, 
    x0 = 0, y0 = 0}, device_transform_inverse = {xx = 1, yx = 0, xy = 0, yy = 1, x0 = 0, 
    y0 = 0}, device_transform_observers = {next = 0x7f5f94705148, prev = 0x7f5f94705148}, 
  x_resolution = 72, y_resolution = 72, x_fallback_resolution = 300, 
  y_fallback_resolution = 300, snapshot_of = 0x0, snapshot_detach = 0x7f5fa095196e, 
  snapshots = {next = 0x7f5f94705188, prev = 0x7f5f94705188}, snapshot = {
    next = 0xfffffff10000002f, prev = 0x0}, font_options = {
    antialias = CAIRO_ANTIALIAS_DEFAULT, subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT, 
    lcd_filter = CAIRO_LCD_FILTER_DEFAULT, hint_style = CAIRO_HINT_STYLE_DEFAULT, 
    hint_metrics = 16856, round_glyph_positions = 26}}

(gdb) p *(surface->backend)
$4 = {type = 4098, create_similar = 0, 
  finish = 0x7f5fb32ea79c <_cairo_analysis_surface_finish>, acquire_source_image = 0, 
  release_source_image = 0, acquire_dest_image = 0, release_dest_image = 0, clone_similar = 0, 
  composite = 0, fill_rectangles = 0, composite_trapezoids = 0, create_span_renderer = 0, 
  check_span_renderer = 0, copy_page = 0, show_page = 0, 
  get_extents = 0x7f5fb32ea7ee <_cairo_analysis_surface_get_extents>, old_show_glyphs = 0, 
  get_font_options = 0, flush = 0, mark_dirty_rectangle = 0, scaled_font_fini = 0, 
  scaled_glyph_fini = 0, paint = 0x7f5fb32ea8e7 <_cairo_analysis_surface_paint>, 
  mask = 0x7f5fb32ea9ca <_cairo_analysis_surface_mask>, 
  stroke = 0x7f5fb32eabab <_cairo_analysis_surface_stroke>, 
  fill = 0x7f5fb32ead2e <_cairo_analysis_surface_fill>, 
  show_glyphs = 0x7f5fb32eae7c <_cairo_analysis_surface_show_glyphs>, snapshot = 0, 
  is_similar = 0, fill_stroke = 0, create_solid_pattern_surface = 0, 
  can_repaint_solid_pattern_surface = 0, 
  has_show_text_glyphs = 0x7f5fb32eb08a <_cairo_analysis_surface_has_show_text_glyphs>, 
  show_text_glyphs = 0x7f5fb32eb0b3 <_cairo_analysis_surface_show_text_glyphs>, 
  acquire_source_image_transformed = 0}

and status=104 is CAIRO_INT_STATUS_IMAGE_FALLBACK.

Going up another level, to #4:

(gdb) p *source
$6 = {type = CAIRO_PATTERN_TYPE_SOLID, ref_count = {ref_count = 0}, 
  status = CAIRO_STATUS_SUCCESS, user_data = {size = 0, num_elements = 0, element_size = 24, 
    elements = 0x0}, matrix = {xx = 1, yx = 0, xy = 0, yy = 1, x0 = -48.25, y0 = -48.25}, 
  filter = CAIRO_FILTER_GOOD, extend = CAIRO_EXTEND_PAD, has_component_alpha = 0}

(gdb) p *glyphs
$7 = {index = 3, x = 213.02500000000001, y = 410.90000000000003}

(gdb) p *scaled_font
$8 = {hash_entry = {hash = 2869133258}, status = CAIRO_STATUS_SUCCESS, ref_count = {
    ref_count = 60}, user_data = {size = 0, num_elements = 0, element_size = 24, 
    elements = 0x0}, original_font_face = 0x7f5f9630d180, font_face = 0x7f5f9630d180, 
  font_matrix = {xx = 15, yx = 0, xy = 0, yy = 15, x0 = 0, y0 = 0}, ctm = {xx = 1, yx = 0, 
    xy = 0, yy = 1, x0 = 0, y0 = 0}, options = {antialias = CAIRO_ANTIALIAS_SUBPIXEL, 
    subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB, lcd_filter = CAIRO_LCD_FILTER_DEFAULT, 
    hint_style = CAIRO_HINT_STYLE_NONE, hint_metrics = CAIRO_HINT_METRICS_OFF, 
    round_glyph_positions = CAIRO_ROUND_GLYPH_POS_OFF}, placeholder = 0, holdover = 0, 
  finished = 0, scale = {xx = 15, yx = 0, xy = 0, yy = 15, x0 = 0, y0 = 0}, scale_inverse = {
    xx = 0.066666666666666666, yx = 0, xy = 0, yy = 0.066666666666666666, x0 = -0, y0 = -0}, 
  max_scale = 15, extents = {ascent = 13.92333984375, descent = 3.53759765625, 
    height = 17.4609375, max_x_advance = 26.00830078125, max_y_advance = 0}, fs_extents = {
    ascent = 0.92822265625, descent = 0.23583984375, height = 1.1640625, 
    max_x_advance = 1.73388671875, max_y_advance = 0}, mutex = {__data = {__lock = 0, 
      __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, 
        __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}, 
  glyphs = 0x7f5f8fdb0340, glyph_pages = {next = 0x7f5f89d39010, prev = 0x7f5f89d5f010}, 
  cache_frozen = 0, global_cache_frozen = 0, surface_backend = 0x0, surface_private = 0x0, 
  backend = 0x7f5fb35f30c0, link = {next = 0x7f5f8fdc39d0, prev = 0x7f5f8fdc39d0}}

(gdb) p *clip
$9 = {path = 0x7f5f89d78800, all_clipped = 0}

(gdb) p *(clip->path)
$10 = {ref_count = {ref_count = 106}, path = {last_move_point = {x = 12352, y = 12352}, 
    current_point = {x = 12352, y = 12352}, has_current_point = 1, needs_move_to = 1, 
    has_extents = 1, has_curve_to = 0, stroke_is_rectilinear = 1, fill_is_rectilinear = 1, 
    fill_maybe_region = 0, fill_is_empty = 0, extents = {p1 = {x = 12352, y = 12352}, p2 = {
        x = 144320, y = 190400}}, buf = {base = {link = {next = 0x7f5f89d78830, 
          prev = 0x7f5f89d78830}, num_ops = 5, size_ops = 27, num_points = 4, 
        size_points = 54, op = 0x7f5f89d78860 "", points = 0x7f5f89d7887c}, 
      op = "\000\001\001\001\003\000\000\000\000\000\000\000\000\340V@\232\231\231\231\231\225q at J\000", points = {{x = 12352, y = 12352}, {x = 144320, y = 12352}, {x = 144320, y = 190400}, {
          x = 12352, y = 190400}, {x = 102144, y = 19712}, {x = 1081185689, y = 72}, {x = 0, 
          y = -1717986918}, {x = 1079816601, y = -1717986918}, {x = 1081185689, y = 3}, {
          x = 0, y = -1717986918}, {x = 1079962009, y = -1717986918}, {x = 1081185689, 
          y = 48}, {x = 0, y = 858993460}, {x = 1080036659, y = -1717986918}, {x = 1081185689, 
          y = 72}, {x = 0, y = -858993459}, {x = 1080162508, y = -1717986918}, {
          x = 1081185689, y = 79}, {x = 0, y = -858993459}, {x = 1080235212, y = -1717986918}, 
        {x = 1081185689, y = 79}, {x = 0, y = 1717986918}, {x = 1080274534, y = -1717986918}, {
          x = 1081185689, y = 82}, {x = 0, y = 0}, {x = 1080313856, y = -1717986918}, {
          x = 1081185689, y = 81}, {x = 0, y = -858993459}, {x = 1080387788, y = -1717986918}, 
        {x = 1081185689, y = 3}, {x = 0, y = 0}, {x = 1080466944, y = -1717986918}, {
          x = 1081185689, y = 56}, {x = 0, y = 1717986919}, {x = 1080505958, y = -1717986918}, 
        {x = 1081185689, y = 81}, {x = 0, y = -858993459}, {x = 1080609484, y = -1717986918}, {
          x = 1081185689, y = 76}, {x = 0, y = 0}, {x = 1080688640, y = -1717986918}, {
          x = 1081185689, y = 89}, {x = 0, y = -1717986918}, {x = 1080727961, 
          y = -1717986918}, {x = 1081185689, y = 72}, {x = 0, y = -858993459}, {
          x = 1080797388, y = -1717986918}, {x = 1081185689, y = 85}, {x = 0, y = -858993459}, 
        {x = 1080870092, y = -1717986918}, {x = 1081185689, y = 86}, {x = 0, y = 1717986919}, {
          x = 1080928870, y = -1717986918}, {x = 1081185689, y = 76}}}}, 
  fill_rule = CAIRO_FILL_RULE_WINDING, tolerance = 0.10000000000000001, 
  antialias = CAIRO_ANTIALIAS_DEFAULT, prev = 0x0, extents = {x = 48, y = 48, width = 516, 
    height = 696}, flags = 6, region = 0x0, surface = 0x0}


I don't see anything there which should cause the error.

Or, for that matter, where status is set to image_fallback.

The bug may be related to the support for splitting StandardEncoding
text runs out from the rest.

I posted here for discussion and for any thoughts on how to better debug
it.  The crash is reasonably reproducible, but the job does require some
complexity and I've not yet hit on the trigger.

If I compile cairo with NDEBUG the app does not exit but the postscript
file is empty.

-JimC
-- 
James Cloos <cloos at jhcloos.com>         OpenPGP: 1024D/ED7DAEA6




More information about the cairo mailing list