Pinging some EXR files results in fatal System.AccessViolationException
Magick.NET version
Magick.NET.Core, Version ^13.9.1
Environment (Operating system, version and so on)
Windows 11 Pro, 23H2
Description
When pinging the exr file that can be found in this zip, the process crashes with the following exception:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
at ImageMagick.MagickImageCollection+NativeMethods+X64.MagickImageCollection_ReadStream(IntPtr, ReadWriteStreamDelegate, SeekStreamDelegate, TellStreamDelegate, Void*, IntPtr ByRef)
--------------------------------
at ImageMagick.MagickImageCollection+NativeMagickImageCollection.ReadStream(ImageMagick.IMagickSettings`1<Single>, ReadWriteStreamDelegate, SeekStreamDelegate, TellStreamDelegate, Void*)
at ImageMagick.MagickImageCollection+NativeMagickImageCollection.ReadStream(ImageMagick.IMagickSettings`1<Single>, ReadWriteStreamDelegate, SeekStreamDelegate, TellStreamDelegate)
at ImageMagick.MagickImageCollection.AddImages(System.IO.Stream, ImageMagick.IMagickReadSettings`1<Single>, Boolean)
at ImageMagick.MagickImageCollection.Ping(System.IO.Stream, ImageMagick.IMagickReadSettings`1<Single>)
...
The issue should be reproducible by doing something along the lines of:
<read-exr-file-as-stream>
using var magickImageCollection = new MagickImageCollection();
magickImageCollection.Ping(exrStream, null);
I have tested that this also is an issue in 13.10.0 and 14.0.0
This works in version 13.6.0.
Steps to Reproduce
See the description above.
Thanks for reporting this. It turns out ImageMagick cannot read these images because we only support scanline images. But there is a bug in the part of the code that reports the error. I just pushed a patch to the ImageMagick repository to fix this. This bug will be fixed in the next release.
@dlemstra Thanks! Out of curiosity: If ImageMagick can not read these image, then how come that it works in Magick.NET.Core 13.6.0?
There might have been changes in the exr api or how we are using it. I will need to investigate that but I don't know when I will make time for that.
I had some time tonight and I was able to restore support for reading tiled images with the new api of openexr that is used by ImageMagick. In the next release you will be able to read this image again.