LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Segmentation Fault (https://www.linuxquestions.org/questions/linux-general-1/segmentation-fault-47865/)

live2 03-02-2003 06:26 AM

Segmentation Fault
 
I have recently put together a new comoputer, I think it's a 2GHZ athalon (quite an improvement over the 233 MHZ pentium I had been using). I have installed Redhat 8.0, and it seems to work for the most part. I have a perl script that I use to resize jpg files, which uses ImageMagick, and it works on the three other computers I use, all ao which have some version or other of Redhat on them. When I run this little script on my new computer it tells me segmentation fault. First, what, more or less, is a segmentation fault?

I have tried to troubleshoot the program by commenting out all of the lines that reffered to ImageMagick, and then running the program to see which line was causing the error. It seems that the offending line is the following:

$image->Read(file=>\*PICS);

I don't know if this is a hardware problem or a software problem, and I have no idea how to proceed. I would deeply appreciate any help.

Thanks

quietguy47 03-02-2003 08:19 AM

What is the error message?

kater 03-02-2003 08:44 AM

A segfault (=Segmentation Fault) is an unexpected error in a programm routine. Simply: Your programm crashed.

Crashed_Again 03-02-2003 08:53 AM

Quote:

I have a perl script that I use to resize jpg files, which uses ImageMagick, and it works on the three other computers I use, all ao which have some version or other of Redhat on them.
If these are older versions of RedHat then they probably have different versions of perl on them. Is it possible that the newer version of perl that you have is not backwards compatible?

live2 03-02-2003 09:56 AM

The error message is simply "Segmentation fault" with exactly that capitalization(or lack thereof). It is a very simple script (I'm a simple programmer) so it seems unlikely that it would be a change in perl or the perl interface to ImageMagick. Do you think that I should contact the ImageMagick people and ask them? I will include the whole script since it is so short. I use it all the time, and if anyone else wants to use it, feel free. You have to make sure that you have the perl interface to ImageMagick installed.

#!/usr/bin/perl

#Program to resize all .jpg files in current directory and save them as a.jpg. first argument is height, second argument is width.

$width=pop(@ARGV);
$height=pop(@ARGV);

use Image::Magick;
$image = Image::Magick->new;
@files=`ls *.jpg`;
foreach $file (@files){
$file=~s/.jpg//;
chomp ($file);
open PICS, "<${file}.jpg" or die "cannot open ${file}.jpg";
binmode PICS;
$image->Read(file=>\*PICS);
close PICS;
$image->Resize(width=>$width, height=>$height);
print "${file}a.jpg\n";
open PICS, ">${file}a.jpg" or die "cannot open ${file}a.jpg";
$image->Write(file=>PICS);
close PICS;
undef @$image;
}

cuckoopint 03-02-2003 12:04 PM

Quote:

I have recently put together a new comoputer, I think it's a 2GHZ athalon
umm...you built a computer, but don't know exactly what the cpu is....? ;)

Quote:

First, what, more or less, is a segmentation fault?
Segemntation fault is when your program tries to use memory that has not been allocated to it - since, you wrote this program, maybe you should look through it for memory problems - most likely a buffer overrun.

jetblackz 03-02-2003 08:36 PM

I would run

www.memtest86.com

for 15-30 mins before jumping into conclusion.


All times are GMT -5. The time now is 11:37 AM.