Quick fix for strange Ruby errors

Well, maybe not fix but tip how to find some clues what next.

Quick Fix
on CC license

When You encounter strange errors like terminate called after throwing an instance of 'int' this is probably something with roots down into Ruby executable or some binary library (and ruby binary dump – ruby.core file in current directory). AFAIK this is error message from GCC, that means something wrong happened on low level – low from Ruby perspective.

It is not very informative message, so to get know what is really happening usually is enough to enable debug:

$DEBUG=true

In You Ruby application. With debugging enabled, all exceptions (event those catched) are dumped to STDERR, so usually last one will give some hint, at least in which area is problem.

For me it was:

Exception `RuntimeError' at test/functional/receiver_controller_test.rb:9 - FreeImage exception for type JPEG: JPEG parameter struct mismatch: library thinks size is 464, caller expects 428
DIRECTORY/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb:14: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-freebsd6]

No, I don’t know yet what is really happening, I hope that ongoing FreeImage upgrade will do the trick.

Join the Conversation

7 Comments

  1. Looks like mismatch between some library and native extension. Haven’t you upgraded some OS components (libraries) ? That most common case if you’ve got structure mismatch

  2. @Pawel
    I’m not sure what was reason that ImageScience has refused to work. Application was written with RMagick in mind, so adding :proccessor option in attachement_fu helped ‘solve’ problem.

    The point is how to get past meaningless message when Ruby dumps it’s core – just enable $DEBUG

    EDITED:
    This message was from FreeBSD on VMWare which is my place to make experiments – so I don’t expect that libraries/packages will be there coherent and up to date :) Deployment will be on Linux boxes with own libs/dependency problems ;)

  3. @Brian
    I had on my dev machine installed both ImageScience and RMagick. Attachemnt Fu prefers IS before RM, so using :processor (has_attachment option) to force attachment_fu use RMagic did the trick for me.

    I hope that will help You. If You want to stick with ImageScience – I had some outdated libs on my BSD box, so if switch to RM is not solution for You do check if Your system has newest libraries.

  4. Hi,

    Thanks for the response. Yeah I went through a lot of work to switch to Image Science because I thought my app had memory leaks from RMagick. But after switching I haven’t noticed a significant difference so maybe that wasn’t the problem.

    I have freeimage 3.9 which is a little out of date but not much. I guess if it persists I can try going back to RMagick.

    Thanks!
    Brian

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.