[cairo] [PATCH] initialize clip_region when creating a new win32_surface

Shixin Zeng zeng.shixin at gmail.com
Wed Aug 26 14:28:26 PDT 2009


The current git HEAD fails to run any win32 cairo program, I've tested programs in GtkTests, all fail, even the following minimal program taken from FAQ on cairo website fails.

include <cairo.h>

int
main (int argc, char *argv[])
{
        cairo_surface_t *surface;
        cairo_t *cr;

        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        cr = cairo_create (surface);

        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
        cairo_set_font_size (cr, 32.0);
        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
        cairo_move_to (cr, 10.0, 50.0);
        cairo_show_text (cr, "Hello, world");
        cairo_destroy (cr);
        cairo_surface_write_to_png (surface, "hello.png");
        cairo_surface_destroy (surface);

        return 0;
}

with the exception:
Unhandled exception at 0x100cfbd7 (libcairo-msvcr90d.dll) in example-msvcr90d.dll: 0xC0000005: Access violation reading location 0xcdcdcdcd.

and call stack:
>	libcairo-msvcr90d.dll!cairo_region_destroy(_cairo_region * region=0xcdcdcdcd)  Line 315 + 0x9 bytes	C
 	libcairo-msvcr90d.dll!_cairo_win32_surface_set_clip_region(void * abstract_surface=0x00998338, _cairo_region * region=0x00000000)  Line 707 + 0xf bytes	C
 	libcairo-msvcr90d.dll!_cairo_win32_surface_flush(void * abstract_surface=0x00998338)  Line 1544 + 0xb bytes	C
 	libcairo-msvcr90d.dll!cairo_surface_flush(_cairo_surface * surface=0x00998338)  Line 976 + 0x10 bytes	C
 	libcairo-msvcr90d.dll!cairo_surface_finish(_cairo_surface * surface=0x00998338)  Line 647 + 0x9 bytes	C
 	libcairo-msvcr90d.dll!cairo_surface_destroy(_cairo_surface * surface=0x00998338)  Line 583 + 0x9 bytes	C
 	libcairo-msvcr90d.dll!_cairo_win32_scaled_font_show_glyphs(void * abstract_font=0x009c2ca8, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * pattern=0x0012ebd0, _cairo_surface * generic_surface=0x00996dd0, int source_x=12, int source_y=26, int dest_x=12, int dest_y=26, unsigned int width=190, unsigned int height=30, cairo_glyph_t * glyphs=0x0012e3d0, int num_glyphs=12, _cairo_region * clip_region=0x00000000, int * remaining_glyphs=0x0012d0a4)  Line 1446 + 0x9 bytes	C
 	libcairo-msvcr90d.dll!_cairo_scaled_font_show_glyphs(_cairo_scaled_font * scaled_font=0x009c2ca8, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * pattern=0x0012ebd0, _cairo_surface * surface=0x00996dd0, int source_x=12, int source_y=26, int dest_x=12, int dest_y=26, unsigned int width=190, unsigned int height=30, cairo_glyph_t * glyphs=0x0012e3d0, int num_glyphs=12, _cairo_region * clip_region=0x00000000)  Line 2042 + 0x4b bytes	C
 	libcairo-msvcr90d.dll!_cairo_surface_old_show_glyphs_draw_func(void * closure=0x0012d5c0, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * src=0x0012ebd0, _cairo_surface * dst=0x00996dd0, int dst_x=0, int dst_y=0, const _cairo_rectangle_int * extents=0x0012d5d4, _cairo_region * clip_region=0x00000000)  Line 1128 + 0x57 bytes	C
 	libcairo-msvcr90d.dll!_clip_and_composite(_cairo_clip * clip=0x00000000, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * src=0x0012ebd0, _cairo_status (void *, _cairo_operator, const _cairo_pattern *, _cairo_surface *, int, int, const _cairo_rectangle_int *, _cairo_region *)* draw_func=0x100ded10, void * draw_closure=0x0012d5c0, _cairo_surface * dst=0x00996dd0, const _cairo_rectangle_int * extents=0x0012d5d4)  Line 479 + 0x24 bytes	C
 	libcairo-msvcr90d.dll!_cairo_surface_fallback_show_glyphs(_cairo_surface * surface=0x00996dd0, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * source=0x0012ebd0, cairo_glyph_t * glyphs=0x0012e3d0, int num_glyphs=12, _cairo_scaled_font * scaled_font=0x009c2ca8, _cairo_clip * clip=0x00000000)  Line 1174 + 0x22 bytes	C
 	libcairo-msvcr90d.dll!_cairo_surface_show_text_glyphs(_cairo_surface * surface=0x00996dd0, _cairo_operator op=CAIRO_OPERATOR_OVER, const _cairo_pattern * source=0x0012ebd0, const char * utf8=0x00415748, int utf8_len=12, cairo_glyph_t * glyphs=0x0012e3d0, int num_glyphs=12, const cairo_text_cluster_t * clusters=0x0012dbbc, int num_clusters=0, _cairo_text_cluster_flags cluster_flags=0, _cairo_scaled_font * scaled_font=0x009c2ca8, _cairo_clip * clip=0x00000000)  Line 2531 + 0x21 bytes	C
 	libcairo-msvcr90d.dll!_cairo_gstate_show_text_glyphs(_cairo_gstate * gstate=0x009931b0, const char * utf8=0x00415748, int utf8_len=12, const cairo_glyph_t * glyphs=0x0012f5b4, int num_glyphs=12, const cairo_text_cluster_t * clusters=0x00000000, int num_clusters=0, _cairo_text_cluster_flags cluster_flags=0)  Line 1702 + 0x73 bytes	C
 	libcairo-msvcr90d.dll!cairo_show_text(_cairo * cr=0x00993190, const char * utf8=0x00415748)  Line 3276 + 0x2e bytes	C
 	example-msvcr90d.dll!main(int argc=1, char * * argv=0x00996c60)  Line 16 + 0x11 bytes	C
 	example-msvcr90d.dll!__tmainCRTStartup()  Line 582 + 0x19 bytes	C
 	example-msvcr90d.dll!mainCRTStartup()  Line 399	C



More information about the cairo mailing list