Subject: Re: bug#20802: Segfault when showing non-GTK+ tooltip

From: Eli Zaretskii <[email-masked]>
Date: Mon, 15 Jun 2015 18:01:58 +0300

> Date: Mon, 15 Jun 2015 10:22:40 +0200
> From: martin rudalics <[email-masked]>
> CC: [email-masked], [email-masked]
> 
>  > Thanks.  Now I know why this cannot be reproduced on Windows: this is
>  > bug#17524 coming back to haunt us.  That bug was reported on Windows,
>  > I fixed it on Windows, then suggested a similar fix for X, but was
>  > told it didn't help there.
>  >
>  > So now please try making a fix on X similar to commit ebdc80316, and
>  > if that indeed doesn't help with this crash, perhaps some simple
>  > variation of that will.
> 
> Sorry.  I must be missing something very elementary here.  Your "shadow"
> refcounts
> 
> #ifdef GLYPH_DEBUG
> static int image_cache_refcount, dpyinfo_refcount;
> #endif
> 
> are defined iff you have GLYPH_DEBUG defined.  How are these supposed to
> work when GLYPH_DEBUG is not defined?

It cannot, obviously.  Bug#17524 was reported in the GLYPH_DEBUG code:
the assertion there segfaulted when it tried to access the image
cache.  So the code was fixed only for that situation.

Doing that for a non-GLYPH_DEBUG code will require the shadow variable
to come out of that condition as well.  Or use some other flag
variable to indicate that x_free_frame_resources is about to be called
when the refcount was not yet incremented.

IOW, that bug was mentioned as a source of ideas, not as something to
copy verbatim to xfns.c.  Sorry if I was unclear about that.