>> this certainly cures my problem with PerlMagick, it clobbers the tests
> Can you post a short PerlMagick script we can use to reproduce the problem?
> If so, we might be able to add a robust patch for the problem within a day or
> two.
Certainly - apologies that this is a long post:
#!/usr/bin/perl
#
# Demonstrate the seg fault.
#
# System: RedHat Enterprise Linux 5.1 (64-bit)
# Perl: 5.8.8
# ImageMagick: 6.3.9-4
#
# Built using: ./configure --prefix=/usr --libdir=/usr/lib64
#
# Makefiles modified to remove optimization to avoid variable
# 'optimized out' in GDB trace.
#
# Run as: gdb --directory=/home/mick/ImageMagick-6.3.9 --args perl
./im_seg_fault.pl
#
# Breakpoint set on DestroyBlob() and CloseBlob()
#
use Image::Magick;
$file1 = "test_pic1.jpg"; # File is 1024x768 JPEG image
&saveImage;
exit 0;
sub saveImage {
my $image = Image::Magick->new;
open(IMG,"<$file1") or die "Cannot open $file1 for reading\n";
warn "$file1 open\n";
my $err = $image->ReadImage(file=>\*IMG);
close(IMG);
warn "$file1 read and file closed\n";
#
# We could do anything here - let's just resize it
#
$err = $image->ResizeImage(width=>640,height=>480);
#
# Now write it out
#
open(OUT,">new_$file1") or die ("Cannot open new_$file1 for writing\n");
warn "new_$file1 open\n";
$err = $image->WriteImage(file=>\*OUT,filename=>"new_$file1");
warn "new_$file1 written\n";
close(OUT);
warn "new_$file1 closed\n";
#
# $image is still in scope bit we have closed the
# file handle and the Blob still exists because of
# image->blob->exempt
#
# Resized image has been written but as
# soon as we return we will get a seg fault
#
warn "Leaving saveImage\n";
}
This is the output:
test_pic1.jpg open
test_pic1.jpg read and file closed
new_test_pic1.jpg open
new_test_pic1.jpg written
new_test_pic1.jpg closed
Leaving saveImage
Segmentation fault
Running under gdb - I've preceded the Perl script output with ***:
GNU gdb Red Hat Linux (6.5-16.el5rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...(no debugging symbols
found)
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) b DestroyBlob
Function "DestroyBlob" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (DestroyBlob) pending.
(gdb) b CloseBlob
Function "CloseBlob" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (CloseBlob) pending.
(gdb) run
Starting program: /usr/bin/perl ./im_seg_fault.pl
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 46912496239104 (LWP 19994)]
(no debugging symbols found)
Breakpoint 3 at 0x2aaaae28b001: file magick/blob.c, line 585.
Pending breakpoint "DestroyBlob" resolved
Breakpoint 4 at 0x2aaaae28ad38: file magick/blob.c, line 475.
Pending breakpoint "CloseBlob" resolved
***test_pic1.jpg open
[Switching to Thread 46912496239104 (LWP 19994)]
Breakpoint 4, CloseBlob (image=0x1eaa46c0) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Breakpoint 4, CloseBlob (image=0x1eaa46c0) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Breakpoint 3, DestroyBlob (image=0x1eaa46c0) at magick/blob.c:585
585 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Breakpoint 4, CloseBlob (image=0x1eaa46c0) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Breakpoint 4, CloseBlob (image=0x1eab1ca0) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
***test_pic1.jpg read and file closed
Breakpoint 3, DestroyBlob (image=0x1ea9e470) at magick/blob.c:585
585 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Breakpoint 3, DestroyBlob (image=0x1eab1ca0) at magick/blob.c:585
585 assert(image != (Image *) NULL);
(gdb) c
Continuing.
***new_test_pic1.jpg open
Breakpoint 4, CloseBlob (image=0x1eac8730) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
***new_test_pic1.jpg written
***new_test_pic1.jpg closed
***Leaving saveImage
Breakpoint 3, DestroyBlob (image=0x1eac8730) at magick/blob.c:585
585 assert(image != (Image *) NULL);
(gdb) print image->blob
$1 = (BlobInfo *) 0x1e9b0470 # The blob still exists even though we closed the
file
(gdb) c
Continuing.
Breakpoint 4, CloseBlob (image=0x1eac8730) at magick/blob.c:475
475 assert(image != (Image *) NULL);
(gdb) c
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x000000363485e640 in fflush () from /lib64/libc.so.6
(gdb) bt full
#0 0x000000363485e640 in fflush () from /lib64/libc.so.6
No symbol table info available.
#1 0x00002aaaae290b30 in SyncBlob (image=0x1eac8730) at magick/blob.c:3466
status = 0
__PRETTY_FUNCTION__ = "SyncBlob"
#2 0x00002aaaae28ae2c in CloseBlob (image=0x1eac8730) at magick/blob.c:482
status = 32767
__PRETTY_FUNCTION__ = "CloseBlob"
#3 0x00002aaaae28b122 in DestroyBlob (image=0x1eac8730) at magick/blob.c:597
destroy = MagickTrue
__PRETTY_FUNCTION__ = "DestroyBlob"
#4 0x00002aaaae347592 in DestroyImage (image=0x1eac8730) at magick/image.c:1505
destroy = MagickTrue
__PRETTY_FUNCTION__ = "DestroyImage"
#5 0x00002aaaae01cffd in XS_Image__Magick_DESTROY (my_perl=0x1e98b010,
cv=<value optimized out>) at Magick.xs:3223
message = "\000\000\000\000\000\000\000\000yKÈ66\000\000\000
w¢\036\000\000\000\000°F§\036\000\000\000\000~òdv\000\000\000\000xbÈ66\000\000\000\000àÂ\221ÿ\177\000\000¨Y¡\036\000\000\000\000P\017\233\036",
'\0' <repeats 13 times>, "[EMAIL PROTECTED]", '\0' <repeats 12 times>,
"¬eÈ66"...
hv = <value optimized out>
sv = <value optimized out>
sp = (SV **) 0x1ea159a8
ax = <value optimized out>
#6 0x0000003636c90916 in Perl_pp_entersub () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#7 0x0000003636c33947 in Perl_magicname () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#8 0x0000003636c376a0 in Perl_call_sv () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#9 0x0000003636c95066 in Perl_sv_clear () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#10 0x0000003636c95810 in Perl_sv_free () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#11 0x0000003636c95377 in Perl_sv_clear () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#12 0x0000003636c95810 in Perl_sv_free () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#13 0x0000003636c89440 in Perl_av_undef () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#14 0x0000003636c9547c in Perl_sv_clear () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#15 0x0000003636c95810 in Perl_sv_free () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#16 0x0000003636cb8aa5 in Perl_leave_scope () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#17 0x0000003636c8c27d in Perl_pp_leavesub () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#18 0x0000003636c8a1de in Perl_runops_standard () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#19 0x0000003636c3803a in perl_run () from
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so
No symbol table info available.
#20 0x000000000040179c in main ()
No symbol table info available.
(gdb)
I hope this helps you to fix this - the problem becomes acute when processing
large numbers of images in a loop.
Regards,
Mick.
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users