Suggestion for new option -error-mode

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Suggestion for new option -error-mode

Post by findus »

In windows, you can alter the behavior when your program crashes by calling the SetErrorMode function in the windows API. See: http://msdn.microsoft.com/en-us/library ... s.85).aspx

The only way to set this on another process is by inheritance.

Sometimes I would like to run some ImageMagick component in an error mode that is not default and not the same as the program that starts the ImageMagick process, and this is not possible right now.

I would therefore like to propose a new option for ImageMagick components for windows that sets the error mode before doing any actual work (Preferably as early as possible). It should support the same options as the windows API function, and could for example look like this:

Code: Select all

-error-mode mode
Where mode is an integer that can be for example 3 for the options SEM_FAILCRITICALERRORS and SEM_NOGPFAULTERRORBOX. (See the link above for documentation)
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Suggestion for new option -error-mode

Post by dlemstra »

What is the problem you are trying to solve? Is one of the ImageMagick programs crashing? That should not happen.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Re: Suggestion for new option -error-mode

Post by findus »

Yes, that is the problem I am trying to solve.

Ideally no ImageMagick component would ever crash, but that is not the case. (I have several files that causes crashes and displays windows crash dialogues) I doubt there will ever be a version that is guaranteed not to crash under any circumstances.

Of course, known bugs should be solved to prevent ImageMagick components from crashing, but I want this option for example to be sure that I don't get a windows crash dialogue.

And don't get me wrong here, I think ImageMagick is awsome, and the rare cases where I get a crash are with files that are clearly corrupt. I don't expect ImageMagick to make something out of corrupt files, I just want to be sure that I don't get any windows crash dialogues.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Suggestion for new option -error-mode

Post by dlemstra »

'Ignoring' the error would result in even stranger behavior. A corrupt image should not cause a crash. Can you share your images so we can fix that crash? Feel free to send me a PM if you don't want to publicly post your image.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Re: Suggestion for new option -error-mode

Post by findus »

Yes, I can share the images but you are totally missing the point. Even if this specific crash should be fixed, there is no guarantee that I will not find another file that causes another crash due to another bug.

I do not agree that it would cause even stranger behavior to suppress the Windows crash dialogue, the only difference would be that instead of Windows waiting for the user to click a "Close" button on the crash dialogue, the crashed process would be terminated without user interaction.

The reason that this is an issue for me, is because I use ImageMagick to convert lots of images in an automated process, and if something goes wrong with an image, I don't want the crash dialogue to appear since that would require user interaction.

I will send you the images in a PM, but I want it to be clear that solving the bug that causes the crash on these specific files that I have does not solve the problem I have described. Adding the -error-mode option would.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Suggestion for new option -error-mode

Post by dlemstra »

I would like to thank you for sending me those images. There was a bug in the tiff reader that was causing the crash. The corrupt images you send me will be handled without crashing in the next release of ImageMagick (6.8.8.5). I understand you would prefer that we add the 'move along, nothing to see here' option but we rather fix a bug that causes one of our programs to crash. You helped to prevent other people from running into the same problem. Please contact us in the future if you have images that cause a crash so we can fix it and make all our users happy.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Suggestion for new option -error-mode

Post by snibgo »

If I understand findus properly, the problem isn't that IM crashes, but that manual intervention is required before other image processing can proceed. I also do batch work with IM under Windows, and I always report problems, but it is highly frustrating to find that the processing of a few hundred thousand images could have finished with a single error except that Windows is waiting for me to acknowledge that error.

I don't understand the technicalities of findus's proposal. I do write my own (trivial) C++ programs, and when they fail from a corrupt file or whatever, they send a message to stderr and exit(n) so the caller can process the error and continue with other work. ImageMagick is far more complex, of course.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Suggestion for new option -error-mode

Post by magick »

In ImageMagick 6.8.8-5, available sometime tomorrow, we support the MAGICK_ERRORMODE environment variable.
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Re: Suggestion for new option -error-mode

Post by findus »

dlemstra: I agree with you that fixing bugs are important, which is why I sent you those files. Good work on fixing the bug! However you don't seem to have understood what my real problem is. I want to be absolutely sure that a windows crash dialogue requiring user interaction does not pop up.

snibgo: Yes, that is exactly what i mean! Thank you for rephrasing my problem :)

magick: If that is what it sounds like, thank you so much! But where can I find documentation for this environment variable?
Last edited by findus on 2014-02-10T01:39:30-07:00, edited 1 time in total.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Suggestion for new option -error-mode

Post by dlemstra »

The environment variable expects an integer value. If you want to set SEM_FAILCRITICALERRORS and SEM_NOGPFAULTERRORBOX you should set MAGICK_ERRORMODE to 3 (1 | 2 = 3)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Re: Suggestion for new option -error-mode

Post by findus »

Perfect! Thank you very much!

On a sidenote: Is there an overview of all environment variables somewhere?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Suggestion for new option -error-mode

Post by magick »

User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Suggestion for new option -error-mode

Post by fmw42 »

Out of curiosity, why is this new environment variable windows only? Seems like other OS could benefit also.
findus
Posts: 14
Joined: 2012-08-14T07:57:42-07:00
Authentication code: 67789

Re: Suggestion for new option -error-mode

Post by findus »

It relies on a function in the Windows API called SetErrorMode. I don't know if other OS's have something similar. (Or even a problem that is similar)
Post Reply