2 * Copyright © 2004 Red Hat, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Red Hat, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior
11 * permission. Red Hat, Inc. makes no representations about the
12 * suitability of this software for any purpose. It is provided "as
13 * is" without express or implied warranty.
15 * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
18 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Carl D. Worth <cworth@cworth.org>
28 * 2004-11-04 Ned Konz <ned@squeakland.org>
30 * Reported bug on mailing list:
32 * From: Ned Konz <ned@squeakland.org>
33 * To: cairo@cairographics.org
34 * Date: Thu, 4 Nov 2004 09:49:38 -0800
35 * Subject: [cairo] getting assertions [cairo_cache.c:143: _entry_destroy:
36 * Assertion `cache->used_memory > entry->memory' failed]
38 * The attached program dies on me with the assert
41 * testCairo: cairo_cache.c:143: _entry_destroy: Assertion `cache->used_memory > entry->memory' failed.
43 * 2004-11-04 Carl Worth <cworth@cworth.org>
45 * I trimmed down Ned's example to the folllowing test while still
46 * maintaining the assertion.
48 * Oh, actually, it looks like I may have triggered something
51 * text_cache_crash: cairo_cache.c:422: _cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed.
53 * I'll have to go back and try the original test after I fix this.
55 * 2004-11-13 Carl Worth <cworth@cworth.org>
57 * Found the bug. cairo_gstate_select_font was noticing when the
58 * same font was selected twice in a row and was erroneously failing
59 * to free the old reference. Committed a fix and verified it also
60 * fixed the orginal test case.
63 #include "cairo-test.h"
65 static cairo_test_draw_function_t draw
;
69 "Test case for bug causing an assertion failure in _cairo_cache_lookup",
75 static cairo_test_status_t
76 draw (cairo_t
*cr
, int width
, int height
)
78 /* Once there was a bug that choked when selecting the same font twice. */
79 cairo_select_font_face (cr
, "sans",
80 CAIRO_FONT_SLANT_NORMAL
, CAIRO_FONT_WEIGHT_BOLD
);
81 cairo_set_font_size (cr
, 40.0);
83 cairo_select_font_face (cr
, "sans",
84 CAIRO_FONT_SLANT_NORMAL
, CAIRO_FONT_WEIGHT_BOLD
);
85 cairo_set_font_size (cr
, 40.0);
86 cairo_move_to (cr
, 10, 50);
87 cairo_show_text (cr
, "hello");
89 /* Then there was a bug that choked when selecting a font too big
92 /* XXX: Sometimes this leads to an assertion:
94 _cairo_cache_lookup: Assertion `cache->max_memory >= (cache->used_memory + new_entry->memory)' failed.
97 But other times my machine hangs completely only to return to life
98 several minutes later with some programs missing. This seems like
99 the out-of-memory killer to me.
101 It seems like I usually get the assertion when I run
102 ./text_cache_crash directly and I usually get the machine hang when
103 I run "make check" but I don't know if there's a perfect
106 So there's a bad bug here somewhere that really needs to be fixed.
107 But in the meantime, I need "make check" not to destory work, so
108 I'm commenting this test out for now.
110 cairo_set_font_size (cr, 500);
111 cairo_show_text (cr, "hello");
114 return CAIRO_TEST_SUCCESS
;
120 return cairo_test (&test
);