unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problem with image libraries on Windows (reprise)
@ 2005-06-15 10:34 Juanma Barranquero
  2005-06-15 10:34 ` Juanma Barranquero
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Juanma Barranquero @ 2005-06-15 10:34 UTC (permalink / raw)


I've already discussed this on the "Problem with library images on
Windows (again)" [yeah, there's a word reversal on the subject that I
didn't notice till now], but I'm doing a reprise there so I can get
feedback and fix the problem ASAP.

Problem:
  Image functions that load JPEG and PNG images from a FILE * can
crash Emacs on Windows.  In particular:
    - MSVC builds of Emacs crash when using either MinGW or MSVC
builds of the libraries
    - MinGW builds of Emacs crash when using MSVC builds of the libraries

Cause:
  Documentation for the JPEG library states: " Microsoft C cannot pass
file pointers between applications and DLLs. (See Microsoft Knowledge
Base, PSS ID Number Q50336.) " I've been unable to find article
Q50336, probably because it is very old, but the description of the
problem seems to fit what I find. Moreover, tracing calls all the way
through NTDLL shows that the Windows library is receiving an non-valid
FILE * (but the image DLLs are receiving a valid one, so it is not a
problem in Emacs).

Fix:
  Both libraries (jpeglib and libpng) allow setting up custom reading
functions. This allows the libraries to call back into program space,
where the FILE * can be safely used. The fix for libpng is almost
trivial, just adding one tiny function; jpeglib has a slightly more
complex protocol and requires defining a bunch of functions for
initializing the data source, filling the temporary buffer and
skipping unwanted input data.

Problems:
  - With the PNG fix, there should be none. My patch changes the
method for reading from FILE * for all platforms, because it seems
better to have one single code and the callback method should work
fine everywhere. However, I can make this change conditional to
HAVE_NTGUI if deemed necessary.
  - With the JPEG fix: none technical. However, the code I've used is
lifted from jdatasrc.c on the jpeglib distribution, so there could be
legal problems. Datapoints:
   - The code is pretty much jdatasrc.c, with only a few names changed
and little more.
   - It is similar to the already installed code for jpeg_memory_src,
installed by Gerd on 1999-12-31.
   - Documentation for the problem I'm trying to fix explicitly
states: "So jdatasrc.c and
  jdatadst.c don't work if you open a file in your application and then pass
  the pointer to the DLL.  One workaround is to make jdatasrc.c/jdatadst.c
  part of your main application rather than part of the DLL."
   - Jpeglib docs have this bit of legalese: "(1) If any part of the
source code for this software is distributed, then this README file
must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original
files must be clearly indicated in accompanying documentation."

Actions:
  I'm sending the two fixes as separate patches, so people can give
feedback on them separately.
  - With regard to the PNG patch, I'd like an answer about making it
the only way to read PNG image from files, or using it only for
Windows.
  - On the JPEG front: Richard should make a comment about the legal
issues. If the code cannot be included as is, I'd like for someone
who's not been "tainted" by looking at jdatasrc.c to reimplement it.

The patches follow in the next messages on this thread.

Thanks,

                    /L/e/k/t/u

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

end of thread, other threads:[~2005-10-05 14:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15 10:34 Problem with image libraries on Windows (reprise) Juanma Barranquero
2005-06-15 10:34 ` Juanma Barranquero
2005-06-15 10:35 ` Juanma Barranquero
2005-06-16  3:46 ` David Hunter
2005-06-16  8:39   ` Juanma Barranquero
2005-06-22 13:18 ` Juanma Barranquero
2005-10-05 14:46   ` Juanma Barranquero

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).