summaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-12-18 00:00:31 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-12-18 00:00:31 -0800
commit423e8af5fd21022f9107100c8561c5f880121231 (patch)
tree0e115adfbb1f1bd6923853438c9d56e73bf2083e /opcode.h
parent3500db162fc97aafc7cfeaa8c61f6c681810e3b4 (diff)
downloadperl-423e8af5fd21022f9107100c8561c5f880121231.tar.gz
Stop seek($glob_copy...) from clearing PL_last_in_gv
seek had the same bug as tell. Here is the commit message from 8dc99089, which fixed tell: ---------------------------------------------------------------------- Stop tell($glob_copy) from clearing PL_last_in_gv This bug is a side effect of rv2gv’s starting to return an incoercible mortal copy of a coercible glob in 5.14: $ perl5.12.4 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' 0 $ perl5.14.0 -le 'open FH, "t/test.pl"; $fh=*FH; tell $fh; print tell' -1 In the first case, tell without arguments is returning the position of the filehandle. In the second case, tell with an explicit argument that happens to be a coercible glob (tell has an implicit rv2gv, so tell $fh is actu- ally tell *$fh) sets PL_last_in_gv to a mortal copy thereof, which is freed at the end of the statement, setting PL_last_in_gv to null. So there is no ‘last used’ handle by the time we get to the tell without arguments. This commit adds a new rv2gv flag that tells it not to copy the glob. By doing it unconditionally on the kidop, this allows tell(*$fh) to work the same way. Let’s hope nobody does tell(*{*$fh}), which will unset PL_last_in_gv because the inner * returns a mortal copy. This whole area is really icky. PL_last_in_gv should be refcounted, but that would cause handles to leak out of scope, breaking programs that rely on the auto-closing ‘feature’.
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/opcode.h b/opcode.h
index 00d27f876c..709e92c431 100644
--- a/opcode.h
+++ b/opcode.h
@@ -1546,7 +1546,7 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
Perl_ck_fun, /* syswrite */
Perl_ck_eof, /* eof */
Perl_ck_tell, /* tell */
- Perl_ck_fun, /* seek */
+ Perl_ck_tell, /* seek */
Perl_ck_trunc, /* truncate */
Perl_ck_fun, /* fcntl */
Perl_ck_fun, /* ioctl */