Bug 79906 - Perl segfaults with particular scripts.
Perl segfaults with particular scripts.
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: perl (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Chip Turner
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-12-17 17:49 EST by dwmalone
Modified: 2007-04-18 12:49 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-08-14 13:44:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Sample perl script & data file to demonstrate write command segfault (10.00 KB, application/x-tar)
2003-08-14 13:21 EDT, Edward Farrar
no flags Details

  None (edit)
Description dwmalone 2002-12-17 17:49:57 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.1) Gecko/20021201

Description of problem:
Perl segfaults when given the script below. Whatever is happening
is quite strange 'cos it depends on the "split(...)" line, which
shouldn't have any interesting side effects.

22:45:graves 153% cat test.pl
#!/usr/bin/perl

format =
^<<<<<<
$blah
.

%test = (1 => 2);

foreach $blah (keys %test) {
        split(/\n/, $test{$data});
        write;
}
22:45:graves 154% perl test.pl
1
Segmentation fault (core dumped)




Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Try the above script.
 

Actual Results:  As shown.

Expected Results:  22:48:gonzo 12% perl test.pl
1


Additional info:

This test script does something similar to the rdistcf.pl script
which is used to sumarise rdist output.The version of perl we have
is

22:48:graves 156% rpm -q perl
perl-5.8.0-55

it worked OK with the privious version. As a workaround you can do
"$blah .= '';" as the first statement in the foreach loop!
Comment 1 Edward Farrar 2003-08-14 10:40:21 EDT
Hello,

I am seeing similar behavior with perl-5.8.0-88.  However, the description
states the problem is related to the split command.  I ran the test script and
got the segmentation fault.  I commented out the split command and still got the
segmentation fault, so I'm not sure if split is related to the problem or not.

The script that I have, that has worked on previous versions, also segmentation
faults.  It appears, however, that the problem is with the write command.  My
script is formatting text for a report.  Where multiple lines are displayed for
a variable, the write command appears to miss the end of the string and keep
going into undefined memory.  I was able to reformat the variable using an
sprintf and force the size of the variable to be greater than the maximum the
write command would output.  This stopped the segmentation fault.

Even with the padded variable, the write command woudl still not format the text
correctly.  It appears to miss word breaks and it is splitting lines
incorrectly.  Oddly enough, the same script run on the same version of Perl
(5.8.0), but on a Sun Solaris 9 system, does not segmentation fault and produces
the correct output.

Below is my test script, sample data that it formats, output from the RedHat
system and output from the Sun system.


------------------- Perl Script ------------------
#!/usr/bin/perl
                                                                                
                                                                                
format STDOUT_TOP=
                       DAILY OPERATIONS LOG
                                                                                
                             DATE @||||||||                            PAGE
@>>>$dt,$FORMAT_PAGE_NUMBER
================================================================================
                                                                               
.
                                                                                
format STDOUT =
@<<<<<<<< @<<<<<      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<    @<<< @<<< @<<<
$dt,$tm,$ac,$su,$op1,$op2
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
~                     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ac
________________________________________________________________________________ 
.
 
#Open the file.
open (INPUT, "log2.dat") || die "Could not open data file: $!\n";
 
#Start reading form the file.
while ($inline = <INPUT>)
{
        chomp ($inline);
        next if $inline == "";
        ($dt,$tm,$su,$op1,$op2,$ac) = split (/\|/, $inline, 6);
        write;
 
}
 
#close the file
close (INPUT);
exit (0);

-------------------- log2.dat data file (one entry per line) -----------------
08/11/03|0000|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0001|JMM|TFF|RAP|Started level 0 backups on WWW.
08/11/03|0100|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0132|JMM|TFF|RAP|Completed Level 0 backups on WWW.
08/11/03|0200|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0300|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0400|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0500|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0600|JMM|TFF|RAP|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0700|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0800|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0805|BMC|JRV|BR|XXXXX, XXXXXXX and XXXXXXX 100% idle from 0000 - 0800
is 0 minutes.
08/11/03|0850|BMC|JRV|BR|XXX XXXXX (X. XXXXXX/X. XXXXXXXX) arrived to do daily
checks in 800 Ton Chiller Farm.
08/11/03|0858|BMC|JRV|BR|XXX XXXX. completed daily checks and departed area.
08/11/03|0900|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|0940|BMC|JRV|BR|XXX XXXX X. XXXXX and XXX XX X. XXXXXXXX investigating
SSA1 DISK OPERATION - RESOURCE UNAVAILABLE error messages on XXXXXXXXX Frame 23
& 24 Partition 1.
08/11/03|1000|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1010|BMC|JRV|BR|XXX XXXX X. XXXXX and XXX XX X. XXXXXXXX replaced SSA1
disk on XXXXXXXXX Frame 23 & 24 Partition 1. Frames available for use.
08/11/03|1100|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1200|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1300|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1400|BMC|JRV|BR|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1500|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1600|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1605|CRB|MJW|HE|XXXXX, XXXXXXX and XXXXXXX 100% idle from 0800 - 1600
is 0 minutes.
08/11/03|1700|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1800|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|1900|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|2000|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.
08/11/03|2100|CRB|MJW|HE|ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE TO USERS.

-------------------------- RedHat output (segmentation fault) --------------
bash-2.05b$ ./t7.pl
                       DAILY OPERATIONS LOG
 
                             DATE 08/11/03                             PAGE
================================================================================ 
08/11/03  0000        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO
________________________________________________________________________________ 
08/11/03  0001        Started level 0 backups on WWW.              JMM  TFF  RAP
                      AILABLE TO USERS.
                                        STDOUT_TOP
                         :utf8 :utf8 1   $ B$ B
                      DAILY OPERATIONS LOG
                      DATE 08/11/03
                      PAGE ==========================
                      ===============================
                      =======================   a   À#
                      # BÀ# B
                              à#Bà#B        0   h
                                              ^<<<<<<
                      <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      <<<           )
                           h   i
                      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      <<<<<<<<<<           )
                                      !       0¦ @  f
________________________________________________________________________________ 
08/11/03  0100        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO
________________________________________________________________________________ 
08/11/03  0132        Completed Level 0 backups on WWW.            JMM  TFF  RAP
                      <<<<<<<           )
                              `   i
                      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      <<<<<<<<           )
                                  i
                      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      <<<<<<<<           )
                                  !       0¦ @  f
                                 !       0¦ @  f
                                i
                      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
TEMS ARE AVAILABLE TO <<<<<<<<           )
                                  i
                      ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                      <<<<<<<<           )
                                  q   _________________
                      _________________________________
                      ______________________________
________________________________________________________________________________ 
08/11/03  0200        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO
08/11/03  0300        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO
08/11/03  0400        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO
Segmentation fault

-------------------------- Sun output (correct) ----------------------

                       DAILY OPERATIONS LOG
                                                                                
                             DATE 08/11/03                             PAGE
================================================================================
                                                                               
08/11/03  0000        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________
                                                                               
08/11/03  0001        Started level 0 backups on WWW.              JMM  TFF 
RAP________________________________________________________________________________
                                                                               
08/11/03  0100        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________
                                                                               
08/11/03  0132        Completed Level 0 backups on WWW.            JMM  TFF 
RAP________________________________________________________________________________ 
08/11/03  0200        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________ 
08/11/03  0300        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________ 
08/11/03  0400        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________ 
08/11/03  0500        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________ 
08/11/03  0600        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      JMM  TFF  RAP
                     TO USERS.
________________________________________________________________________________ 
08/11/03  0700        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  0800        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  0805        XXXXX, XXXXXXX and XXXXXXX 100% idle from    BMC  JRV  BR
                      0000 - 0800 is 0 minutes.
________________________________________________________________________________ 
08/11/03  0850        XXX XXXXX (X. XXXXXX/X. XXXXXXXX) arrived    BMC  JRV  BR
                      to do daily checks in 800 Ton Chiller
                      Farm.
________________________________________________________________________________ 
08/11/03  0858        XXX XXXX. completed daily checks and         BMC  JRV  BR
                      departed area.
________________________________________________________________________________ 
                       DAILY OPERATIONS LOG
 
                             DATE 08/11/03                             PAGE
================================================================================ 
08/11/03  0900        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  0940        XXX XXXX X. XXXXX and XXX XX X. XXXXXXXX     BMC  JRV  BR
                      investigating SSA1 DISK OPERATION -
                      RESOURCE UNAVAILABLE error messages on
                      XXXXXXXXX Frame 23 & 24 Partition 1.
________________________________________________________________________________ 
08/11/03  1000        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1010        XXX XXXX X. XXXXX and XXX XX X. XXXXXXXX     BMC  JRV  BR
                      replaced SSA1 disk on XXXXXXXXX Frame 23
                      & 24 Partition 1. Frames available for
                      use.
________________________________________________________________________________ 
08/11/03  1100        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1200        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1300        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1400        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      BMC  JRV  BR
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1500        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1600        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1605        XXXXX, XXXXXXX and XXXXXXX 100% idle from    CRB  MJW  HE
                      0800 - 1600 is 0 minutes.
________________________________________________________________________________ 
08/11/03  1700        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
                       DAILY OPERATIONS LOG
 
                             DATE 08/11/03                             PAGE
================================================================================ 
08/11/03  1800        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
08/11/03  1900        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
08/11/03  2000        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 
08/11/03  2100        ALL XXXX XXX XXXX SYSTEMS ARE AVAILABLE      CRB  MJW  HE
                      TO USERS.
________________________________________________________________________________ 


Comment 2 Chip Turner 2003-08-14 12:01:56 EDT
the original example breakage seems fixed with the perl in rawhide.  can you
test there, and/or produce a smaller test case (and please attach as a file,
don't paste into a comment).  thanks.
Comment 3 Edward Farrar 2003-08-14 13:21:37 EDT
Created attachment 93643 [details]
Sample perl script & data file to demonstrate write command segfault

Sample script and data file that shows the write command segmentation fault.
Comment 4 Chip Turner 2003-08-14 13:44:11 EDT
this works in the perl in rawhide, so it looks like it was fixed upstream

Note You need to log in before you can comment on or make changes to this bug.