Page 1 of 1

Disable assert/abort

Posted: 2011-08-16T08:57:18-07:00
by avejidah
Using magick++, is it possible to disable the assertions/aborts on corrupt image reads without modifying the library? It seems strange that the library would throw an exception and assert/abort.

Code: Select all

  Image img;

  try 
  {
    img.read(argv[1]);
  }
  catch (exception& ex) 
  {
    cout << "Caught: " << ex.what() << endl;
  }

Code: Select all

Caught: Magick: Corrupt JPEG data: 3052 extraneous bytes before marker 0xd9 `2011-02-27_16-04-00_280.jpg' @ jpeg.c/EmitMessage/227
Not continuing - bad image.
imageTest: magick/semaphore.c:288: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.
Aborted
I have a daemon that is processing images in the background. I don't want the daemon to die just because it encounters a single corrupt image. I do want to know when it encounters a corrupt image, but I want to catch the error and continue.

Ubuntu 10.04
Default libmagick++-dev version from the repositories
$ echo `dpkg -l |grep magick++-dev`
ii libmagick++-dev 7:6.5.7.8-1ubuntu1.1 object-oriented C++ interface to ImageMagick

Thanks.

Re: Disable assert/abort

Posted: 2011-08-16T09:36:53-07:00
by magick
Its possible this problem is fixed in later versions of ImageMagick. Can you post a URL to your corrupt image. We'll see if we can reproduce the problem-- if so we'll get a patch to fix it.

Re: Disable assert/abort

Posted: 2011-08-16T09:42:38-07:00
by avejidah
Thanks for the quick response. Grab the corrupt image here: http://busybin.com/corrupt.jpg. Yea yea, I'm goofy lookin' =)

Re: Disable assert/abort

Posted: 2011-08-16T10:46:55-07:00
by magick
Classic. All problems are fixed in the release you don't have installed on your system. We tried your Magick++ snippet and the exception was thrown properly and exited without an assertion error:

  • -> magick++
    Caught: Magick: Corrupt JPEG data: 3046 extraneous bytes before marker 0xd9 `corrupt.jpg' @ warning/jpeg.c/JPEGWarningHandler/327

    -> echo "Yeah, it worked"
    Yeah, it worked
    ->
We're using ImageMagick 6.7.1-6.

Re: Disable assert/abort

Posted: 2011-08-16T10:53:56-07:00
by avejidah
Cool, thanks. Hopefully that version will be added to the Ubuntu repositories at some point. For now, I'll grab it on my dev system. Thanks again!