unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problem with library images on Windows (again)
@ 2005-05-18 15:53 Juanma Barranquero
  2005-05-18 19:30 ` Andreas Schwab
  2005-05-18 22:16 ` Jason Rumney
  0 siblings, 2 replies; 37+ messages in thread
From: Juanma Barranquero @ 2005-05-18 15:53 UTC (permalink / raw)


For some time now, TIFF images do crash optimized MSVC builds of Emacs
when using the MinGW-supplied TIFF library.

The crash happens in image_spec_value(), but it all boils down to the
fact that on lookup_image(), after

         img->load_failed_p = img->type->load (f, img) == 0;

the value of the argument "spec" cannot be trusted. This is easy to prove; with

   static LispObject spec_backup;
   spec_backup = spec;

   img->load_failed_p = img->type->load (f, img) == 0;

   spec = spec_backup;
   spec_backup = Qnil;

everything works as expected.

Now, when this happened before (with the local variable img) someone
said that the MinGW libraries were not respecting calling conventions,
but I'm not sure. Calling conventions for MSVC say that you cannot
trust EAX, EBX, ECX, EDX, ESI, or EDI registers after a subroutine
call, and AFAICS, the problem is that on optimized builds VC is
expecting spec to still be cached in a register.

So, I can apply the attached patch and at least stop Emacs from
crashing on Windows, but I certainly would appreciate a more
insightful analysis from the "people in the know" wrt image support
and/or Windows.

-- 
                    /L/e/k/t/u

Index: src/image.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/image.c,v
retrieving revision 1.23
diff -u -2 -r1.23 image.c
--- src/image.c	10 May 2005 09:16:46 -0000	1.23
+++ src/image.c	18 May 2005 15:38:22 -0000
@@ -1663,9 +1663,20 @@
       extern Lisp_Object Qpostscript;
 
+#ifdef _MSC_VER
+      static Lisp_Object spec_backup;
+      spec_backup = spec;
+#endif
+
       BLOCK_INPUT;
       img = make_image (spec, hash);
       cache_image (f, img);
+
       img->load_failed_p = img->type->load (f, img) == 0;
 
+#ifdef _MSC_VER
+      spec = spec_backup;
+      spec_backup = Qnil;
+#endif
+
       /* If we can't load the image, and we don't have a width and
 	 height, use some arbitrary width and height so that we can

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2005-06-14  9:15 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-18 15:53 Problem with library images on Windows (again) Juanma Barranquero
2005-05-18 19:30 ` Andreas Schwab
2005-05-18 22:44   ` Juanma Barranquero
2005-05-19  6:58     ` Jason Rumney
2005-05-18 22:16 ` Jason Rumney
2005-05-18 22:52   ` Juanma Barranquero
2005-05-19  3:50     ` Eli Zaretskii
2005-05-19  8:13       ` Juanma Barranquero
2005-05-19 19:05         ` Eli Zaretskii
2005-05-19 19:31           ` Juanma Barranquero
2005-05-19 19:32             ` Juanma Barranquero
2005-05-20  7:20             ` Eli Zaretskii
2005-05-20  8:24               ` Kim F. Storm
2005-05-20 10:01                 ` Eli Zaretskii
2005-05-20 10:16                 ` Jason Rumney
2005-05-20 10:42                   ` Juanma Barranquero
2005-05-20 14:44                     ` Eli Zaretskii
2005-05-20 15:46                       ` Jason Rumney
2005-05-20 15:52                         ` Eli Zaretskii
2005-05-20 16:33                           ` Juanma Barranquero
2005-05-20 17:57                             ` Juanma Barranquero
2005-05-21 10:21                               ` Jason Rumney
2005-05-21 10:33                                 ` Juanma Barranquero
2005-05-21 21:13                                   ` Jason Rumney
2005-05-22 21:21                                     ` Juanma Barranquero
2005-06-03 12:08                                       ` Juanma Barranquero
2005-06-03 13:06                                         ` David Kastrup
2005-06-03 15:28                                           ` jasonr
2005-06-03 17:23                                             ` Stefan Monnier
2005-06-05  0:44                                           ` Juanma Barranquero
2005-06-06 11:26                                             ` Juanma Barranquero
2005-06-14  2:02                                               ` Juanma Barranquero
2005-06-14  7:32                                                 ` David Kastrup
2005-06-14  9:15                                                   ` Juanma Barranquero
2005-05-20 16:31                         ` Juanma Barranquero
2005-05-20 16:29                       ` Juanma Barranquero
2005-05-20 12:19                   ` Benjamin Riefenstahl

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).