Bug 110688 - perl's syswrite() seems to have problems on RH9.0
perl's syswrite() seems to have problems on RH9.0
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: perl (Show other bugs)
9
athlon Linux
medium Severity high
: ---
: ---
Assigned To: Warren Togami
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-23 09:19 EST by David Tonhofer
Modified: 2007-04-18 12:59 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-17 19:55:59 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)

  None (edit)
Description David Tonhofer 2003-11-23 09:19:58 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5)
Gecko/20031007

Description of problem:
I wanted to cut apart a large file into smaller blocks 
using a simple Perl program:

-----------------------------------------
#!/usr/bin/perl

$increment = 1000*1024;
$buffer = undef;
$count = 0;

while ($len = sysread(STDIN,$buffer,$increment)) {
  print "$len -> " . length($buffer);
  if (!defined $len) {
    die "System read error: $!\n";
  }
  $name = substr("000000$count",-4,4);
  open(OUT,">out.$name") or die "Could not open: $!";
  $written = syswrite(OUT, $buffer, $len);
  print " -> $written\n";
  close OUT or die "Could not close: $!";
  $count++;
  $buffer = undef;
}
-----------------------------------------

Running it using 

$ perl -w cutter.pl < largefile

produces out.NNNN files of 1024000 byte in principle.

On RH9.0, the resulting files have varying length. This
length is for real, I checked with 'od':

-rw-r--r--    1 root     root      1539448 Nov 23 12:48 out.0000
-rw-r--r--    1 root     root      1540050 Nov 23 12:48 out.0001
-rw-r--r--    1 root     root      1553310 Nov 23 12:48 out.0002
-rw-r--r--    1 root     root      1554432 Nov 23 12:48 out.0003
-rw-r--r--    1 root     root      1538554 Nov 23 12:48 out.0004
-rw-r--r--    1 root     root      1541371 Nov 23 12:48 out.0005
-rw-r--r--    1 root     root      1542505 Nov 23 12:48 out.0006
-rw-r--r--    1 root     root      1540096 Nov 23 12:48 out.0007
-rw-r--r--    1 root     root      1545507 Nov 23 12:48 out.0008
-rw-r--r--    1 root     root      1564212 Nov 23 12:48 out.0009
-rw-r--r--    1 root     root      1569600 Nov 23 12:48 out.0010
-rw-r--r--    1 root     root      1552672 Nov 23 12:48 out.0011

The length of the files is consistent from run to run. Also,
the lengths seem to depend on the file contents.

This has been tested on two different RH9.0 systems (both with
software RAID).

I also tested on a RH7.3 system: no problem

-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0000
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0001
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0002
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0003
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0004
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0005
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0006
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0007
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0008
-rw-r--r--    1 root     root      1024000 Nov 23 14:55 out.0009








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


How reproducible:
Always

Steps to Reproduce:
1. Run perl program
2. Shock!

    

Actual Results:  Length of files is arbitrary but larger than it
should be.

Expected Results:  Length of files should be 1024000.

Additional info:
Comment 1 David Tonhofer 2004-03-10 15:36:34 EST
Ok, while looking through my notes of last year, I came accross this
and having hear about them Perl Internationalization problems, I
decided to test the above with 'LANG=C'. Looks like that fixes it. Is
that good or bad news ;-)
Comment 2 Warren Togami 2005-05-17 19:55:59 EDT
RH9 is no longer supported and has been transferred to the legacy project so
closing this bug.  Please REOPEN only if you can reproduce this on RHEL3, RHEL4,
FC3 or FC4.

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