Subject: Re: bug#38774: crash in image_pix_context_get_pixel

From: [email-masked]
Date: Mon, 30 Dec 2019 15:10:40 +0900

>>
>> Recent emacs configured with
>>
>> configure -C --without-all --with-xml2 --with-dbus --with-m17n-flt
>>  --with-libotf --with-xft --with-x-toolkit=athena
>>  --with-toolkit-scroll-bars --with-xaw3d --with-cairo --with-harfbuzz
>>  --with-png
>>
>> crashes on startup
>
> Could you try the patch below?
>
>      YAMAMOTO Mitsuharu
> [email-masked]
>
> diff --git a/src/image.c b/src/image.c
> index fc90c5ea74..7172bfc810 100644
> --- a/src/image.c
> +++ b/src/image.c
> @@ -1242,6 +1242,10 @@ prepare_image_for_display (struct frame *f, struct
> image *img)
>        if (img->cr_data == NULL || (cairo_pattern_get_type (img->cr_data)
>     != CAIRO_PATTERN_TYPE_SURFACE))
>  {
> +  /* Fill in the background/background_transparent field while
> +     we have img->pixmap->data/img->mask->data.  */
> +  IMAGE_BACKGROUND (img, f, img->pixmap);
> +  IMAGE_BACKGROUND_TRANSPARENT (img, f, img->mask);
>    cr_put_image_to_cr_data (img);
>    if (img->cr_data == NULL)
>      {

Also, could you try if the following patch gives some output in
the terminal from which you invoke Emacs?  I suspect find-image
failed to get a proper tool bar icon image file because
file-readable-p erroneously returned nil.

				     YAMAMOTO Mitsuharu
				[email-masked]

diff --git a/src/fileio.c b/src/fileio.c
index 01f8a04e5d..997faa9820 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -162,6 +162,12 @@ file_access_p (char const *file, int amode)
   if (faccessat (AT_FDCWD, file, amode, AT_EACCESS) == 0)
     return true;

+  if (errno == EINTR)
+    {
+      perror ("faccessat");
+      fprintf (stderr, "file = %s, amode = %d\n", file, amode);
+    }
+
 #ifdef CYGWIN
   /* Return success if faccessat failed because Cygwin couldn't
      determine the file's UID or GID.  */