Catastrophic failure

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Catastrophic failure

Post by oksanen »

I get repeatable failure in imagemagick object in Windows XP. I am running following script:

Code: Select all

Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
do while true
   n=n+1
   jpeg="20110308-070845UTC.jpg"
   timestamp="'"+cstr(n)+"'"
   msgs = img.Convert(jpeg,"-font=C:\Windows\fonts\arial.ttf","-rotate=-90", "-gravity=south", "-stroke='#000C'", "-strokewidth=2", "-pointsize=20", "-draw=text 0,5 "+timestamp, "-fill=yellow", "-stroke=none", "-draw=text 0,5 "+timestamp, "imagemagick_test.jpg")
loop
The conversion fails after 3982 or so calls with following error message:

Code: Select all

C:\Documents and Settings\Sirius\My Documents\canon\imagemagick_test.vbs(7, 4)
(null): Catastrophic failure
Is there any fix or workaround to this available? This is a part of automated program that takes images every five minutes and labels them with Imagemagick. All goes well for about ten days and then the script fails with this error. In my test run I converted the same image in a loop and it fails every time around 3980 cycles. I can supply the source image and the wbscript code if someone wants to try.

The version is 6.6.7-1 Q16.

best regards,

arto
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Catastrophic failure

Post by el_supremo »

I'm not familiar with using IM and VB but I'd say that the problem is that you aren't destroying the ImageObject each time around the loop. I suspect that the image object is growing larger by one image on each pass through the loop until you run out of ram.
Your loop should look something like this:

Code: Select all

Dim img

do while true
   Set img = CreateObject("ImageMagickObject.MagickImage.1")
   n=n+1
   jpeg="20110308-070845UTC.jpg"
   timestamp="'"+cstr(n)+"'"
   msgs = img.Convert(jpeg,"-font=C:\Windows\fonts\arial.ttf","-rotate=-90", "-gravity=south", "-stroke='#000C'", "-strokewidth=2", "-pointsize=20", "-draw=text 0,5 "+timestamp, "-fill=yellow", "-stroke=none", "-draw=text 0,5 "+timestamp, "imagemagick_test.jpg")

>>>Destroy the image object here - I don't know the specific syntax for it
loop
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

el_supremo wrote:I'm not familiar with using IM and VB but I'd say that the problem is that you aren't destroying the ImageObject each time around the loop. I suspect that the image object is growing larger by one image on each pass through the loop until you run out of ram.

Pete
Thanks Pete! This is a good suggestion. But unfortunately it makes no difference. The imagemagick object breaks about the same time even if I destroy and re-create the object in the loop. It is rather strange why this happens.

There is some memory leak, but it is very small. The process takes in the beginning (after the first loop) about 10 000 Kb of memory and at the end about 12 000 kb.

arto
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Catastrophic failure

Post by anthony »

I am not a VB or windows programmer, but I do have a couple of suggestions..

First IM will delay reading in some things like configuration files until it needs them.
As such teh 'type.xml' for fonts or 'colors.xml' for colornames to RGB valuse will not be read in until needed. As such teh first time though the loop may show some memory increase. However larger runs should not show any other increases if everything is removed and destroyed properly.

Of course some languages (I do not know if VB is included in this) have a very lasy garbage collection making this harder.

One suggestion however is to do a 'fake' run with less options and see if you can track down exactly what option is causing the memory leak.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

anthony wrote:One suggestion however is to do a 'fake' run with less options and see if you can track down exactly what option is causing the memory leak.
Hello Anthony!

Good suggestion. I tried to remove as many options as possible and still get the error. The simplest I could get was this:

Code: Select all

msgs = img.Convert("20110308-070845UTC.jpg","-draw=text 0,5 '12345'", "-draw=text 0,5 '12345'", "test.jpg")
This failed after 13350 cycles. If there was only one draw command the script did not fail (or at least not before 40000 cycles).

arto
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

Any help with this one? Another Catastrophic failure occured last night and 5 hours of images were lost.

arto
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

Any progress with this? Just a friendly remainder after another crash (and lost images) last night.

arto
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Catastrophic failure

Post by magick »

Stand by... we're investigating the issue.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Catastrophic failure

Post by magick »

We cannot reproduce your problem. We're using ImageMagick 6.7.2-6, the current release. You VBS script has iterated over 50000 times now without complaint.
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

very good. I will update and run the tests again.

arto
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

I upgraded to ImageMagick-6.7.2-6-Q16-windows-dll.exe

The new test code using "logo:" as the input file.

Code: Select all

Const ERROR_SUCCESS = 0
Dim img
Set img = CreateObject("ImageMagickObject.MagickImage.1")
dim msgs,n
n=0
do while true
  n=n+1
  wscript.echo n
  msgs = img.Convert("logo:","-draw=text 0,5 '12345'", "-draw=text 0,5 '12345'", "imagemagick_test.jpg")
  If Err.Number <> ERROR_SUCCESS Then wscript.echo Err.Number & ": " & Err.Description & vbCrLf
  WScript.Sleep 10
loop
Unfortunatelly the program still fails, now every time after 21429 cycles. I ran the test on two computers with similar results.

C:\Documents and Settings\Digistar3\My Documents\arto> cscript imagemagick_test5.vbs
...
21427
21428
21429
C:\Documents and Settings\Digistar3\My Documents\arto\imagemagick_test5.vbs(9,3) (null): Catastrophic failure

arto
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Catastrophic failure

Post by magick »

We tried your script again and this time its looped over 250,000 times and is still going. We also ran a memory checker against ImageMagick and it did not report any leaks. That leaves 3 possibilities, something about your environment, a leak in ImageMagickObject, or a flaw in your script. We did not write the ImageMagick COM object, its contributed. If the flaw is there, we must depend on a Windows developer to identify and patch. We're not sure that if you need to destroy the ImageMagick object in the your loop. It looks like we are unable to resolve this problem.
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

Thank you for trying! So you are not running the script under Windows? I have Win XP sp3 on the both computers. Because of camera hardware etc. I cannot choose any other operating system.

I have tried both re-using and deleting the object in the loop, neither works.

Is there any way to talk with the windows developer(s)? For me it would be not too difficult to run the script with a debugger and see what is wrong when the error happens. With the last version the error happens every time at the same moment, it is very repeatable.

arto
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Catastrophic failure

Post by magick »

We tested your script under Windows 7, Windows XP, and Windows 2008. It ran fine on all of them for 50,000+ loops.

You are talking with the developers, we're just primarily Linux developers.
oksanen
Posts: 11
Joined: 2011-03-08T06:20:07-07:00
Authentication code: 8675308

Re: Catastrophic failure

Post by oksanen »

And you have ImageMagick-6.7.2-6-Q16-windows-dll.exe ? This is strange. I just ran thge script again and it failed after 21429 cycles.
Is there anything I can do to help locating the problem?

arto
Post Reply