Skip Menu |

This queue is for tickets about the PerlIO-Util CPAN distribution.

Report information
The Basics
Id: 35764
Status: resolved
Priority: 0/
Queue: PerlIO-Util

People
Owner: gfuji [...] cpan.org
Requestors: taro.nishino [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: On 06_tee.t
Hi, Goro, FYI, I'd like to supplement my testers report 1431450 with some related information. With Devel::Peek, I investigated t/06_tee.t line 149 and 153. Dump of slurp($file), line 149, was as follows: SV = PV(0x193da40) at 0x19450c4 REFCNT = 1 FLAGS = (TEMP,POK,pPOK) PV = 0x19a33bc "foobar\n"\0 CUR = 7 LEN = 8 while Dump of "foobar$CRLF", line 149, was as follows: SV = PV(0x193da40) at 0x1944de8 REFCNT = 1 FLAGS = (PADTMP,POK,pPOK) PV = 0x19a33bc "foobar\r\n"\0 CUR = 8 LEN = 12 Also, Dump of slurp($file), line 153, was as follows: SV = PV(0x193da4c) at 0x1880534 REFCNT = 1 FLAGS = (TEMP,POK,pPOK) PV = 0x19a19ac "foobar\n\n"\0 CUR = 8 LEN = 12 while Dump of "foobar$CRLF\n", line 153, was as follows: SV = PV(0x193da4c) at 0x1944e60 REFCNT = 1 FLAGS = (PADTMP,POK,pPOK) PV = 0x19a19ac "foobar\r\n\n"\0 CUR = 9 LEN = 12 In addition to the above, Dump of $x, line 154, was as follows: SV = PV(0x193d9b0) at 0x18305ec REFCNT = 2 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x1831c44 "foobar\r\n\n"\0 CUR = 9 LEN = 12 Regards, Taro Nishino
From: gfuji [...] cpan.org
Hi, Taro. Thanks you for many useful reports. Maybe I has implemented correct binmode(). -------- Goro
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Mon, 12 May 2008 06:34:46 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, Unfortunately, as for PerlIO-Util-0.10, my Perl(ActivePerl Build 817) crashed at the point of running 06_tee.t. I guess its reason is that my compiler is MSVC7.0, while ActivePerl is compiled by MSVC6.0. Unluckily I don't have MSVC6.0. As such, I didn't send testers report because its output made no sense. But, FYI, I'd like to add my information. For finding fault with the crash, I made a test script as follows: #!perl use strict; use warnings; use lib 'C:\temp\PerlIO-Util-0.10\blib\lib'; use FindBin qw($Bin); use File::Spec; use IO::Handle; use Devel::Peek; use PerlIO::Util; PerlIO::Layer->find('tee'); ### FILE ### sub slurp{ my $file = shift; open my $in, '<', $file or die $!; local $/; binmode $in; return scalar <$in>; } my $file = File::Spec->join($Bin, 'util', '.tee'); open(my $tee, '>:tee', \my $x, $file); $tee->autoflush(1); print $tee "foobar"; my $CRLF = "\015\012"; binmode $tee; print $tee "\n"; print "binmode:raw\n"; print "slurp(\$file)\n"; Dump(slurp($file)); print "foobar\\n\n"; Dump("foobar\n"); print "(to main)\n"; Dump($x); print "\n"; # binmode $tee, ':crlf'; print $tee "\n"; print "binmode:crlf\n"; print "slurp(\$file)\n"; Dump(slurp($file)); print "foobar\\n\$CRLF\n"; Dump("foobar\n$CRLF"); print "(to main)\n"; Dump($x); print "\n"; # #binmode $tee; #print $tee "\n"; #print "binmode:raw\n"; #print "slurp(\$file)\n"; #Dump(slurp($file)); #print "foobar\\n\$CRLF\\n\n"; #Dump("foobar\n$CRLF\n"); #print "(to main)\n"; #Dump($x); close $tee; __END__ its results are good, except for the statement commented out. Deleting the comment, however, Perl crashes. All in all, changing from "binmode:crlf" to "binmode:raw" would cause the crash. Regards, Taro Nishino
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Mon, 12 May 2008 10:09:09 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, Although I said that I didn't send testers report, I have sent it after careful consideration. Regards, Taro Nishino
Hi, Taro. I don't have any Visual C++ Compiler. However, I read the binmode routines in perlio.c again, and knew I misunderstanded it. So I have rewrite PerlIOTee_binmode(). Maybe it is corrected. Thanks. -------- Goro
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Tue, 13 May 2008 15:51:39 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, Unfortunately, under ActivePerl and MSVC7.0, 06_tee.t of PerlIO-Util-0.11 failed, too. Its failure occurred at the point of changing from "binmode:crlf" to "binmode:raw". However, in my opinion, is there when we want to change CRLF of binmode while accessing one file? Regards, Taro Nishino
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Fri, 16 May 2008 06:47:51 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, As you can see from the cpan-testers report 1456645, I got that my compiler (MSVC7.0) didn't a matter. I think 06_tee.t is equal to the following. Rather, it's substantial. --- 06_tee.t.org Fri May 16 06:13:16 2008 +++ 06_tee.t Fri May 16 06:19:14 2008 @@ -146,16 +146,22 @@ $tee->autoflush(1); my $CRLF = "\015\012"; +close $tee; +open($tee, '>>:tee', \$x, $file); binmode $tee; print $tee "\n"; is slurp($file), "foobar\n", "binmode:raw"; is $x, "foobar\n", "(to main)"; +close $tee; +open($tee, '>>:tee', \$x, $file); binmode $tee, ':crlf'; print $tee "\n"; is slurp($file), "foobar\n$CRLF", "binmode:crlf"; is $x, "foobar\n$CRLF", "(to main)"; +close $tee; +open($tee, '>>:tee', \$x, $file); binmode $tee; print $tee "\n"; is slurp($file), "foobar\n$CRLF\n", "binmode:raw"; In fact, 06_tee.t passes. Regards, Taro Nishino,
From: gfuji [...] cpan.org
Hi, Taro. Yes. I saw the mingw environment caused the problem. I'll read perlio.c again. However, I have added a simple check code to v0.12 of the binmode routine anyway. -- Goro Fuji (GFUJI@CPAN)
From: gfuji [...] cpan.org
Hi, Taro. At least one bug has been fixed. That is, PerlIOTee_binmode() is expected to return 0 on success, but it retruned 1 (that is returnd by PerlIO_binmode()). -- Goro Fuji (GFUJI@CPAN)
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Tue, 20 May 2008 16:48:56 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, As for PerlIO-Util-0.13, 07_tee_binmode unfortunately failed under MSWIN32. Entering in detail, ".tee1" of line 54 is 0x0D 0x0A 0x0D 0x0A. Incidentally, ".tee2" of line 55 is 0x0D 0x0A 0x0A. Regards, Taro Nishino
From: gfuji [...] cpan.org
Hi, Taro. Thanks. In addition to the details, it seems that 07_tee_binmode.t aborted silently. Uhmm... Thanks. -- Goro Fuji (GFUJI@CPAN)
From: gfuji [...] cpan.org
Hi, Taro. I fixed an issue of breaking newline codes, but unfortunately it is not the problem :-( -- Goro Fuji (GFUJI@CPAN)
Subject: Re: [rt.cpan.org #35764] On 07_tee_binmode(revised from "On 06_tee.t")
Date: Fri, 23 May 2008 00:14:18 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, This time, Perl aborted at the point of 73 Line of 07_tee_binmode as to PerlIO-Util-0.14. There are, however, things you must have overlooked. I did the following test. --- 07_tee_binmode.t.org Thu May 22 15:55:12 2008 +++ 07_tee_binmode.t Thu May 22 23:24:51 2008 @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 40; +use Test::More qw(no_plan); use FindBin qw($Bin); use File::Spec; @@ -70,10 +70,10 @@ is slurp($file1), "foobar\n$CRLF", "binmode:crlf (1)"; is $x, "foobar\n$CRLF", "binmode:crlf (2)"; -ok binmode($tee), 'binmode()'; -print $tee "\n"; -is slurp($file1), "foobar\n$CRLF\n", "binmode:raw (1)"; -is $x, "foobar\n$CRLF\n", "binmode:raw (2)"; +#ok binmode($tee), 'binmode()'; +#print $tee "\n"; +#is slurp($file1), "foobar\n$CRLF\n", "binmode:raw (1)"; +#is $x, "foobar\n$CRLF\n", "binmode:raw (2)"; close $tee; The result of "make test" was as follows: t/00_load.............ok t/01_util.............ok t/02_flock............ok t/03_creat............ok t/04_excl.............ok t/05_extra............ok t/06_tee..............ok t/07_tee_binmode......1/? # Failed test 'binmode:crlf (2)' # at t/07_tee_binmode.t line 92. # got: 'foobar\x0A\x0A' # expected: 'foobar\x0A\x0D\x0A' # Failed test 'binmode:raw (2)' # at t/07_tee_binmode.t line 98. # got: 'foobar\x0A\x0A\x0A' # expected: 'foobar\x0A\x0D\x0A\x0A' # Looks like you failed 2 tests of 37. t/07_tee_binmode...... Dubious, test returned 2 (wstat 512, 0x200) Failed 2/37 subtests t/99_pod..............ok Incidentally, I personally think when changing binmode, the file should be closed once. Who want to mix CRLF into one file? Regards, Taro Nishino
From: gfuji [...] cpan.org
Hi, Taro. Of course no body would like to mix new line codes, but I should avoid segmentation fault. Now I passed through the labyrinth! That is, I succeeded in causing the problem on my platform. The problem that troubled me was found in perlio.c, not in my codes, I think. Run the following, causing SEGV. #!perl use Test::More tests => 3; use PerlIO::via::QuotedPrint; ok binmode STDIN, ':via(QuotedPrint)'; ok binmode STDIN, ':scalar(foo)'; ok binmode STDIN; __END__ I already wrote the patch, and I'll report it as soon as possible. Thank you for a long time! -- Goro Fuji (GFUJI@CPAN)
From: gfuji [...] cpan.org
Hi, Taro. Yes, I've expected some issues on converting new line codes. I'll remove the CRLF tests from the next release. -- Goro Fuji (GFUJI@CPAN)
Subject: Re: [rt.cpan.org #35764] On 06_tee.t
Date: Fri, 23 May 2008 17:58:51 +0900
To: bug-PerlIO-Util [...] rt.cpan.org
From: Taro Nishino <taro.nishino [...] gmail.com>
Hi, Goro, FYI, I'd like to tell you about my weird result. I also ran your "causing SEGV" script. But, its result was as follows: 1..3 ok 1 ok 2 Can't use anonymous symbol table for method lookup at C:\test\Perl\test.pl line 6. # Looks like you planned 3 tests but only ran 2. # Looks like your test died just after 2. So I modified the script as follows: #!perl use Test::More tests => 3; use PerlIO::via::QuotedPrint; ok binmode STDIN, ':via(QuotedPrint)'; ok binmode STDIN, ':scalar(foo)'; ok binmode STDIN, ':raw'; __END__ This script caused SEGV as we expected. Eventually, is the explanation of binmode as follows in perlfunc incorrect? "If LAYER is omitted or specified as :raw the filehandle is made suitable for passing binary data." Regards, Taro Nishino
Hi, Taro. Show quoted text
> This script caused SEGV as we expected. > Eventually, is the explanation of binmode as follows in perlfunc
incorrect? As I reported, the bug of perlio.c is just a mistake, possibly typo. Since it is caused by an illegal memory access, whether segv actually occurs depends on some conditions (perl version, pushing layer, operating system, etc.). So the description is correct (even though the documents on perlio is sometimes insufficient). Thanks, -- Goro Fuji (GFUJI at CPAN.org)
(This is resolved.) -- Goro Fuji (GFUJI at CPAN.org)