List Info

Thread: Blocking Tie::File test under Sunos




Blocking Tie::File test under Sunos
user name
2007-04-17 18:34:32
Hello,

Andy Dougherty wrote in perlsolaris:

 >Running the test suite in SunOS 4.1 is a bit tricky
since the 
*/>lib/Tie/File/t/09_gen_rs/* test hangs (subtest #51,
FWIW) for some 
unknown >reason. Just stop the test and kill that
particular Perl process.

The subtest #51 is correct, although the reason is not
unknown anymore 

It was an endless loop in file lib/Tie/File.pm, sub
_fill_offsets():
  while ( defined $self->_read_record()) {
    # int() saves us memory here
    push OFF, int(tell $fh);
  }

_read_record()
1. reads upto EOF
2. appends the missing newline
in the next invocation
3. reads again and expects EOF, but gets the appended
newline.
  So the current file position was not incremented for
reading :-(

Later invocations of _read_record():
Now it gets scary, since <$fh> happily returns more
and
more content from memory without reaching EOF. It is
probably beyond it.

My patch adds a call of
seek $fh, 0, SEEK_END
after the newline has been appended. The effect is that
eof($fh) is true after that. Proper libc implementations
wont need this, but Sun did not sync the file pointers
during
read, modify, read.

Mark-Jason, I have also traced the reduced testcase
under Linux and SunOS, if you want more details for
the failure. Its in the appendix.

It would be interesting to hear your opinion.

Greetings,
Heiko

*** perl-5.9.4/lib/Tie/File.pm    Tue Aug 15 14:37:41 2006
--- perl-5.9.4-patched/lib/Tie/File.pm    Wed Apr 18
01:22:51 2007
***************
*** 2,8 ****
  package Tie::File;
  require 5.005;
  use Carp 'EFAULT',
'confess';
! use POSIX 'SEEK_SET';
  use Fcntl 'O_CREAT', 'O_RDWR', 'LOCK_EX', 'LOCK_SH',
'O_WRONLY', 
'O_RDONLY';
  sub O_ACCMODE () { O_RDONLY | O_RDWR | O_WRONLY }
 
--- 2,8 ----
  package Tie::File;
  require 5.005;
  use Carp 'EFAULT',
'confess';
! use POSIX 'SEEK_SET', 'SEEK_END';
  use Fcntl 'O_CREAT', 'O_RDWR', 'LOCK_EX', 'LOCK_SH',
'O_WRONLY', 
'O_RDONLY';
  sub O_ACCMODE () { O_RDONLY | O_RDWR | O_WRONLY }
 
***************
*** 926,931 ****
--- 926,932 ----
        local $ = "";
        my $fh = $self->;
        print $fh $self->;
+       seek $fh, 0, SEEK_END;
      }
      $rec .= $self->;
    }


  
Re: Blocking Tie::File test under Sunos
user name
2007-04-17 19:18:47
On Wed, Apr 18, 2007 at 01:34:32AM +0200, Heiko wrote:
> Hello,
> 
> Andy Dougherty wrote in perlsolaris:
> 
> >Running the test suite in SunOS 4.1 is a bit tricky
since the 
> */>lib/Tie/File/t/09_gen_rs/* test hangs (subtest
#51, FWIW) for some 
> unknown >reason. Just stop the test and kill that
particular Perl process.
> 
> The subtest #51 is correct, although the reason is not
unknown anymore 
> 
> It was an endless loop in file lib/Tie/File.pm, sub
_fill_offsets():
>  while ( defined $self->_read_record()) {
>    # int() saves us memory here
>    push OFF, int(tell $fh);
>  }
> 
> _read_record()
> 1. reads upto EOF
> 2. appends the missing newline
> in the next invocation
> 3. reads again and expects EOF, but gets the appended
newline.
>  So the current file position was not incremented for
reading :-(
> 
> Later invocations of _read_record():
> Now it gets scary, since <$fh> happily returns
more and
> more content from memory without reaching EOF. It is
> probably beyond it.
> 
> My patch adds a call of
> seek $fh, 0, SEEK_END
> after the newline has been appended. The effect is
that
> eof($fh) is true after that. Proper libc
implementations
> wont need this, but Sun did not sync the file pointers
during
> read, modify, read.
> 
> Mark-Jason, I have also traced the reduced testcase
> under Linux and SunOS, if you want more details for
> the failure. Its in the appendix.
> 
> It would be interesting to hear your opinion.
> 

I'll have to take a look at the code, but it sure smells
like the usual
Solaris exit() vs. _exit() issues within a child process
without an exec().

Steve Peters
stevefisharerojo.org

Re: Blocking Tie::File test under Sunos
user name
2007-04-18 05:09:02
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )