Svg files without width and height attributes cause Memory leak / Windows crash

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
Roman
Posts: 3
Joined: 2016-02-12T04:11:18-07:00
Authentication code: 1151

Svg files without width and height attributes cause Memory leak / Windows crash

Post by Roman » 2016-02-12T04:35:20-07:00

Hi All,

On reading some svg files ImageMagick crashes a process (if we are using 32-bit process) or crashes Windows 10 (if we are using 64-bit process). To reproduce the issue you can use this code

static void Main(string[] args)
{
for (int i=0; i<100000; i++)
{
MagickImage oMagic = new MagickImage(@"C:\Users\Roman\Documents\tasks\test\2137.svg");

oMagic.Dispose();
}
}

On 32-bit process error is "failed to alllocate 4088 bytes (alignment: 4096): Not enough space.

Tested with the latest Magick.NET-7.0.0.0101-Q16-x64.zip. It's needed to say that standard ImageMagick's command convert also doesn't work (error is: "no images defined").

In this svg file height and width attributes are absent in <svg> element. If I add height and width then everything works as expected.

I think it's ok to have ImageMagick's error "no images defined" but it's not OK to have memory leak. You can take svg to test here: http://1drv.ms/1PqVkfT

Thanks.

User avatar
dlemstra
Posts: 1562
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Post by dlemstra » 2016-02-12T05:16:55-07:00

Thank you for reporting this. I just pushed a patch to our ImageMagick GIT repository to fix this. I will publish a new release of Magick.NET this weekend that will include this fix.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Roman
Posts: 3
Joined: 2016-02-12T04:11:18-07:00
Authentication code: 1151

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Post by Roman » 2016-02-12T05:25:58-07:00

Great. Thank you!

Roman
Posts: 3
Joined: 2016-02-12T04:11:18-07:00
Authentication code: 1151

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Post by Roman » 2016-02-15T06:19:28-07:00

Just checked update -> now the above code throws the 'ImageMagick.MagickMissingDelegateErrorException' exception. I assume that it's the expected behavior. Thanks again.

User avatar
dlemstra
Posts: 1562
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Svg files without width and height attributes cause Memory leak / Windows crash

Post by dlemstra » 2016-02-15T06:36:26-07:00

That is indeed the expected behavior.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply