delilama has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to try out the "Features" method in PerlMagick. But I get a segfault when I call it. I've built the ImageMagick package from source and installed it (this is on an x86_64 Ubuntu 10.04). Here's a snippet of code:
$image->BlobToImage($buffer); my($width, $height, $format) = $image->Get('width', 'height', 'format' +); print "$f\t$width" . "x" . "$height\t$format image.\n"; # works my @features = $image->Features(); # <--- silent segfault here
If I change the call to the following:
my $features = $image->Features();
I get an error: panic: pp_iter at that line. I'm guessing because Features() is supposed to return an array, so this may not be related.

Any ideas?

Replies are listed 'Best First'.
Re: Image::Magick "Features" question
by zentara (Cardinal) on Oct 11, 2011 at 12:35 UTC
      It's listed in the page you linked, under Miscellaneous.
Re: Image::Magick "Features" question
by zentara (Cardinal) on Oct 11, 2011 at 18:28 UTC
    Hi, yeah I see it too, only I get this error if using my @features=.....
    *** glibc detected *** /usr/bin/perl: double free or corruption (!prev +): 0x000000000076a710 ***

    and if I use my $feature = ....; print $feature; I get

    -nan Segmentation fault
    Here is a working test code snippet if anyone cares to try it on their system. It must be an IM bug.
    #!/usr/bin/perl use warnings; use strict; use Image::Magick; my $image = Image::Magick->new( size => "600x600", ); $image->Read("xc:white"); $image->Draw( primitive => 'line', points => "300,100 300,500", stroke => '#600', ); $image->Set(magick=>'jpg'); + my $blob = $image->ImageToBlob(); my $image1 = Image::Magick->new(magick=>'jpg'); $image1->BlobToImage( $blob ); #$output->Resize(geometry=>'160x120'); my($width, $height, $format) = $image1->Get('width', 'height', 'format +'); print "$width" . "x" . "$height\t$format image.\n"; # works # different errors depending on left side structure my @features = $image1->Features(1); # <--- silent segfault here print "@features\n"; #my $features = $image1->Features(1); # <--- silent segfault here #print "$features\n"; $image1->Write( $0.'.jpg');

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Image::Magick "Features" question
by pvaldes (Chaplain) on Oct 11, 2011 at 21:14 UTC

    (...Just wondering why you didn't install the package compiled for your ubuntu version).

    The former code works for me after adding "use diagnostics;" either if I use $image1->Features(1) or $image1->Features()

    If I comment the line "use diagnostics" I got a segfault error

      (...Just wondering why you didn't install the package compiled for your ubuntu version).

      My Ubuntu's version of PerlMagick doesn't have this method.

      I'll try the "use diagnostics;" hack.

      Is there any easy way to debug (via GDB) problems with binary modules in Perl?

        Is there any easy way to debug (via GDB) problems with binary modules in Perl?

        Sure, compile debug version of perl, debug version of imagemagick and all its prerequisites ... fireup gdb and do something gdb-ish with the expert c-knowledge of perl internals :)

        panic: pp_iter

        (P) The foreach iterator got called in a non-loop context frame.

        If it were me, i'd report the bug upstream to all parties concerned :)