Reading PNG Blob images causes access violation on png.c

Antti Luoma <[email protected]> Tue, 30 Oct 2018 14:36:12 +0200
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <CAPCTfgPyha2UZ5d6ZKj+tHZbaqWKFt7POwM3gNHD-Uy+6_vSOA@mail.gmail.com>
Hi,

We have GraphicsMagick integrated into our multi threaded server executable
(made mostly with c). Previously we had ImageMagick (6.x version) but as
GraphicsMagick is now available for vcpkg it is easy to use for Windows
development so we decided to switch to GM. Current version of GM
is 1.3.30-f7e88bedfe.

Our server is multi threaded and we init GM in it main process and also set
our own memory handling routines there as well. We are reading pictures in
worker threads used to serve client requests from Blobs. We have one thread
per client so we also have one wand instance per thread. All libs are
statically linked to our executable with multithreaded option. We use
latest MSVC (vs 2017, Windows 10 SDK) compiler.

Currently we have 2 problems:

1) MagickReadImageBlob() function crashes (access violation 0xFF) in png.c
when it is trying to call setjmp: *if (setjmp(png_jmpbuf(ping))).*

top of stack looks like this:

Symbol name: __intrinsic_setjmp
Symbol name: ReadOnePNGImage
Symbol name: ReadPNGImage
Symbol name: ReadImage
Symbol name: BlobToImage
Symbol name: MagickReadImageBlob

I have been trying to figure out why this access violation happens but I
don't fully understand this. I can comment out the setjmp call and it seems
to work but the we loose the error handling.


2) UnLockSemaphoreInfo() functions are not called after crashes (in other
picture formats as well)  which causes lock to remain if we don't
call DestroyMagick() to release whole library which is not good thing to do
on a multi threaded server very often. Is there a possibility to create
locks per wand and release them in case of error as well? Or is there other
possibilities?

Any help would be nice.

-antti

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help