[cairo] fixing Cairo's FreeType multi-threaded usage

Jan Slupski jslupski at juljas.net
Sun Mar 4 19:56:05 PST 2007


On Sun, 4 Mar 2007, David Turner wrote:

> Hello,
>
> here's a second version of my patchset that fixes the bug described early
> (incorrect behaviour of the FreeType-backed implementation of the toy font
> interface). It needed a few tricky internal changes, but all sems good know.
>
>  http://david.freetype.org/cairo/fix-freetype-usage-2.patchset
>
> note that it was generated against a recent clone of the Cairo git repository,
> you should *not* apply the first patchset before this one.
>
> All test cases pass, except the ones that already failed with the original
> sources.
>
> As usual, all comments are welcomed :-)


Hi David,

Thanks a lot for a patch. It helped a lot.
I can report that 1.3.16 with this patch is often quicker that 1.2.6.

Unfortunately I just hit another problem.
It seems that at certain conditions I hit endless loop
in _cairo_mru_list_remove_select function.

This happens when 'node' that is 'first' element is removed.


I've added some debug code (_cairo_mru_list_remove_select.c)

Here is sample output (when LOOP_WORKAROUND unset) - endless.log
When I switch LOOP_WORKAROUND on I have correct results - workaround.log

Let me know if there is anything else I can provide you with

Jan


    _  _  _  _  _____________________________________________
    | |_| |\ |  S L U P S K I             jslupski at juljas.net
  |_| | | | \|                             http://juljas.net/
-------------- next part --------------
/* destroy all free nodes corresponding a to given selection */
static void
_cairo_mru_list_remove_select (cairo_mru_list_t        *list,
                               cairo_mru_equal_func_t   equal_func,
                               void                    *equal_key)
{
    cairo_mru_t  *first, *node;

    first = list->free_nodes;
    printf("first %p\n", first);
    if (first != NULL) {
	node = first;
	do
	{
	    cairo_mru_t  *node_next = node->next;

	    printf("node: %p next: %p (first is %p)\n", node, node_next, first);

	    if ( (*equal_func) (node, (cairo_mru_t*)equal_key) ) {
		printf("remove %p\n", node);
		_cairo_mru_remove (&list->free_nodes, node);
		list->num_nodes--;
		_cairo_mru_list_free_node (list, node);
		if(getenv("LOOP_WORKAROUND") && node == first ) {
		    printf("Oops removed first!\n");
		    if(list->free_nodes) {
			first = list->free_nodes->prev;
			printf("New first %p\n", first);
		    }
		    else
			break;
		}
	    }
	    node = node_next;
	}
	while (node != first);
    }
}

-------------- next part --------------
first 0x6e0f60
node: 0x6e0f60 next: 0x681500 (first is 0x6e0f60)
node: 0x681500 next: 0x698200 (first is 0x6e0f60)
node: 0x698200 next: 0x691250 (first is 0x6e0f60)
node: 0x691250 next: 0x684a70 (first is 0x6e0f60)
node: 0x684a70 next: 0x6e0f60 (first is 0x6e0f60)
remove 0x684a70
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x6e57b0 (first is 0x667600)
node: 0x6e57b0 next: 0x6e0f60 (first is 0x667600)
node: 0x6e0f60 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x698200 (first is 0x667600)
node: 0x698200 next: 0x691250 (first is 0x667600)
remove 0x698200
node: 0x691250 next: 0x667600 (first is 0x667600)
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x6e57b0 (first is 0x667600)
node: 0x6e57b0 next: 0x6e0f60 (first is 0x667600)
node: 0x6e0f60 next: 0x681500 (first is 0x667600)
remove 0x6e0f60
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x667600 (first is 0x667600)
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
remove 0x667600
node: 0x6e6290 next: 0x6e57b0 (first is 0x667600)
node: 0x6e57b0 next: 0x681500 (first is 0x667600)
remove 0x6e57b0
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x691250 (first is 0x667600)
(...)
-------------- next part --------------
first 0x6e0f60
node: 0x6e0f60 next: 0x681500 (first is 0x6e0f60)
node: 0x681500 next: 0x698200 (first is 0x6e0f60)
node: 0x698200 next: 0x691250 (first is 0x6e0f60)
node: 0x691250 next: 0x684a70 (first is 0x6e0f60)
node: 0x684a70 next: 0x6e0f60 (first is 0x6e0f60)
remove 0x684a70
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x6e57b0 (first is 0x667600)
node: 0x6e57b0 next: 0x6e0f60 (first is 0x667600)
node: 0x6e0f60 next: 0x681500 (first is 0x667600)
node: 0x681500 next: 0x698200 (first is 0x667600)
node: 0x698200 next: 0x691250 (first is 0x667600)
remove 0x698200
node: 0x691250 next: 0x667600 (first is 0x667600)
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
node: 0x6e6290 next: 0x6e57b0 (first is 0x667600)
node: 0x6e57b0 next: 0x6e0f60 (first is 0x667600)
node: 0x6e0f60 next: 0x681500 (first is 0x667600)
remove 0x6e0f60
node: 0x681500 next: 0x691250 (first is 0x667600)
node: 0x691250 next: 0x667600 (first is 0x667600)
first 0x667600
node: 0x667600 next: 0x6e6290 (first is 0x667600)
remove 0x667600
Oops removed first!
New first 0x691250
node: 0x6e6290 next: 0x6e57b0 (first is 0x691250)
node: 0x6e57b0 next: 0x681500 (first is 0x691250)
remove 0x6e57b0
node: 0x681500 next: 0x691250 (first is 0x691250)
first (nil)
first (nil)
first (nil)
first (nil)


More information about the cairo mailing list