seems some Image::Magick stuff i have decided to stop working recently. either that, or there's something wrong with the image i'm trying to resize.

i wanted to try and catch the error, and attempt another resize-and-write with a named block, eval, and redo

from reading the perldoc on redo, i find this:

"redo" cannot be used to retry a block which returns a value such as + "eval {}", "sub {}" or "do {}", and should not be used to exit a gre +p() or map() operation.

which makes me think a code block like this won't DWIM:
warn "new IMG: $fileName " if DEBUG; FILEWRITE: { eval { open( NEWIMG, ">>$fileName" ) or die "Can't open new image +file: ($fileName) $! \n"; binmode( NEWIMG ); $large->Resize( height => $newH, width => $newW ); # or di +e "Resizing error: $! \n"; $large->Write( file => \*NEWIMG ); # or die "Write error: + $!\n"; close( NEWIMG ); }; warn "trying to write the new file ( $fileName ) failed: $@ " +if ( $@ ); redo FILEWRITE if ( $@ ); } undef $large; warn "New LG image written" if DEBUG;
from here, i just return if no thumbnail img is needed, or create one.

i get the first DEBUG line printed to STDERR, but not the second one on a segfault, so i've gotten to the point where it's the FILEWRITE block ... but, i'm not sure *exactly* which part is failing.

so ...

  1. will this redo construct work, or is this one of those explicitly mentioned as not working in the perldoc (i'd think it works since i'm explicitly testing for $@
  2. what could be causing the segfault?
edited: removed the "or die" from the Image::Magick calls ... i added them back in debug, but forgot that they don't have a return value. hoorah infinite loop!

edit 2: after more testing/fighting, it seems that the calling app is segfaulting between a  warn statement and a  return 1; statement. i added a warning right after the object method is called ... and i never see it.

in the calling app:

unless ( -e $useFile and $needThumb && -e $checkThumb ) { warn "resizing $useFile ( and $checkThumb )"; my $resizeOK = $utils->resizeImg( $baseImg, $useFile, $needThum +b ); } warn "done resizing in main app " ;
i never see that last warning ... man, am i ever stuck

In reply to redo question ( part 'catching segfaults' ) by geektron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.