Page 1 of 1

program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-08-24T00:27:16-07:00
by nicolas1
Hello,

I have problem that program crashed on coder warning exception raised:
what: Coder Warning: Corrupt JPEG data: 1027 extraneous bytes before marker 0xd9

Program crashed only one time, but other times program did not get crashed...

Can you provide any hint on this situation? How to make program more stable on such exceptions?

Thanks

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-08-24T20:13:34-07:00
by anthony
Report a bug with a link to a copy of the image. IM should NOT crash, ever. Give warnings and errors yes, crash no.

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-08-25T04:00:01-07:00
by nicolas1
what is expected behavior for IM when Magick::WarningCorruptImage catched ?
As I see "DestroyImageList" function fails (pointer is zero). What happens with resources which were taken by corrupted image?

Also IM crash when attempt to delete corrupted file object. So, resources are not freed...

Btw, how can I post sample image files?

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-08-25T21:01:11-07:00
by anthony
DestroyImageList() will always return a NULL pointer. You use it to assign it back to the image list pointer so you know it is invalid!

Code: Select all

list = DestroyImageList(list)

You put your image up somewhere on the web (anywhere) am post a link to that image.

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-01T20:56:20-07:00
by nicolas1

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-01T21:48:54-07:00
by anthony
Unable to download the images... The download site does not like my multi-host proxy server as a later request can some from a slightly different IP than the previous request!

Can you please start a new topic in BUGS with the original problem and the links to the files.

thank you.

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-02T06:09:51-07:00
by magick
To fix this problem we need a small program we can download to reproduce the problem or a stack trace. We tried converting your DSCF040.JPG image about one hundred times with the latest ImageMagick release, 6.4.3-6, and each time it threw the 'corrupt jpeg data' exception but still exited without crashing.

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-03T15:59:32-07:00
by nicolas1
The problem is memory leak. When c++ exception caught, destroying of Magick::Image object causes program crash. In stack trace it is DestroyImageList(NULL) , while on other magick warnings destroying of Magick::Image object does not make program crash, DestroyImageList(!NULL).

Code: Select all


shared_ptr<Magick::Image> magick_image(new Magick::Image());

 try
{
   magick_image->read(filename_);
}
catch( Magick::WarningCoder &warning )
{
  // this exception is OK.
}
catch (Magick::WarningCorruptImage &warning)
{
  // this causes crash once magick_image becomes out of scope
}


Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-03T16:56:02-07:00
by magick
See http://www.imagemagick.org/Magick++/Exception.html. Your program runs fine if you wrap your code with another try:

Code: Select all

try
{
  try
  {
     magick_image->read(filename_);
  }
  catch( Magick::WarningCoder &warning )
  {
    // this exception is OK.
  }
  catch (Magick::WarningCorruptImage &warning)
  {
    // this causes crash once magick_image becomes out of scope
  }
}
catch( std::exception &error ) 
{ 
   // Process any other exceptions derived from standard C++ exception
   err << “Caught C++ STD exception: “ << error.what() << endl;
} 
catch( ... ) 
{ 
  // Process *any* exception (last-ditch effort). There is not a lot
  // you can do here other to retry the operation that failed, or exit
  // the program. 
}

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-04T02:49:52-07:00
by nicolas1
Yes, resolved. Thanks. Problem was pointer imageInfo()->size was not NULL befor Magick::Image object destruction. Btw, how memory for imageInfo()->size string must be allocated? (Because it seems that IM tries to free it).

Re: program crash on catched coder warning exception (IM 6.3.7)

Posted: 2008-09-04T09:09:37-07:00
by magick
Structured string members, in most cases, should be allocated from the heap:
  • image_info->size = ConstantString("50x50+0+0");