[perl.git] branch blead updated. v5.27.5-329-g1568d13a11

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 1568d13a11564a7d9d62aaf6a79b9b04172a2a45
Author: Zefram 
Date:   Sun Nov 12 05:58:36 2017 +

better document macros taking literal strings

When giving a function-style prototype for a macro taking a literal string
parameter, put a string literal in place of a type for that parameter.
This goofy appearance makes it obvious that this isn't really a function,
and clues the reader in that the parameter can't actually be an arbitrary
expression of the right type.  Also change the nonsensical "NUL-terminated
literal string" to "literal string" to describe these parameters.
Fixes [perl #116286].

---

Summary of changes:
 cop.h   | 16 
 handy.h | 62 +++---
 hv.h|  8 
 pad.h   |  8 
 scope.h |  2 +-
 5 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/cop.h b/cop.h
index 34ebbc09ab..5c66752859 100644
--- a/cop.h
+++ b/cop.h
@@ -190,9 +190,9 @@ associated with the key.
 Perl_refcounted_he_fetch_pvn(aTHX_ cophh, keypv, keylen, hash, flags)
 
 /*
-=for apidoc Amx|SV *|cophh_fetch_pvs|const COPHH *cophh|const char *key|U32 
flags
+=for apidoc Amx|SV *|cophh_fetch_pvs|const COPHH *cophh|"literal string" 
key|U32 flags
 
-Like L, but takes a C-terminated literal string instead
+Like L, but takes a literal string instead
 of a string/length pair, and no precomputed hash.
 
 =cut
@@ -296,9 +296,9 @@ be stored with referential integrity, but will be coerced 
to strings.
 Perl_refcounted_he_new_pvn(aTHX_ cophh, keypv, keylen, hash, value, flags)
 
 /*
-=for apidoc Amx|COPHH *|cophh_store_pvs|const COPHH *cophh|const char *key|SV 
*value|U32 flags
+=for apidoc Amx|COPHH *|cophh_store_pvs|const COPHH *cophh|"literal string" 
key|SV *value|U32 flags
 
-Like L, but takes a C-terminated literal string instead
+Like L, but takes a literal string instead
 of a string/length pair, and no precomputed hash.
 
 =cut
@@ -353,9 +353,9 @@ hash of the key string, or zero if it has not been 
precomputed.
(SV *)NULL, flags)
 
 /*
-=for apidoc Amx|COPHH *|cophh_delete_pvs|const COPHH *cophh|const char 
*key|U32 flags
+=for apidoc Amx|COPHH *|cophh_delete_pvs|const COPHH *cophh|"literal string" 
key|U32 flags
 
-Like L, but takes a C-terminated literal string instead
+Like L, but takes a literal string instead
 of a string/length pair, and no precomputed hash.
 
 =cut
@@ -493,9 +493,9 @@ associated with the key.
 cophh_fetch_pvn(CopHINTHASH_get(cop), keypv, keylen, hash, flags)
 
 /*
-=for apidoc Am|SV *|cop_hints_fetch_pvs|const COP *cop|const char *key|U32 
flags
+=for apidoc Am|SV *|cop_hints_fetch_pvs|const COP *cop|"literal string" 
key|U32 flags
 
-Like L, but takes a C-terminated literal string
+Like L, but takes a literal string
 instead of a string/length pair, and no precomputed hash.
 
 =cut
diff --git a/handy.h b/handy.h
index 77415ecb45..87c45471d1 100644
--- a/handy.h
+++ b/handy.h
@@ -296,78 +296,78 @@ typedef U64TYPE U64;
 /*
 =head1 SV-Body Allocation
 
-=for apidoc Ama|SV*|newSVpvs|const char* s
-Like C, but takes a C-terminated literal string instead of a
+=for apidoc Ama|SV*|newSVpvs|"literal string" s
+Like C, but takes a literal string instead of a
 string/length pair.
 
-=for apidoc Ama|SV*|newSVpvs_flags|const char* s|U32 flags
-Like C, but takes a C-terminated literal string instead of
+=for apidoc Ama|SV*|newSVpvs_flags|"literal string" s|U32 flags
+Like C, but takes a literal string instead of
 a string/length pair.
 
-=for apidoc Ama|SV*|newSVpvs_share|const char* s
-Like C, but takes a C-terminated literal string instead of
+=for apidoc Ama|SV*|newSVpvs_share|"literal string" s
+Like C, but takes a literal string instead of
 a string/length pair and omits the hash parameter.
 
-=for apidoc Am|void|sv_catpvs_flags|SV* sv|const char* s|I32 flags
-Like C, but takes a C-terminated literal string instead
+=for apidoc Am|void|sv_catpvs_flags|SV* sv|"literal string" s|I32 flags
+Like C, but takes a literal string instead
 of a string/length pair.
 
-=for apidoc Am|void|sv_catpvs_nomg|SV* sv|const char* s
-Like C, but takes a C-terminated literal string instead of
+=for apidoc Am|void|sv_catpvs_nomg|SV* sv|"literal string" s
+Like C, but takes a literal string instead of
 a string/length pair.
 
-=for apidoc Am|void|sv_catpvs|SV* sv|const char* s
-Like C, but takes a C-terminated literal string instead of a
+=for apidoc Am|void|sv_catpvs|SV* sv|"literal string" s
+Like C, but takes a literal string instead of a
 string/length pair.
 
-=for apidoc Am|void|sv_catpvs_mg|SV* sv|const char* s
-Like C, but takes a 

[perl.git] branch blead updated. v5.27.5-328-gbc3331071e

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit bc3331071e1ccbdab715397718bb00282f5c5e88
Author: Zefram 
Date:   Sun Nov 12 04:16:13 2017 +

document IO::Select error detection

---

Summary of changes:
 dist/IO/lib/IO/Select.pm | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/dist/IO/lib/IO/Select.pm b/dist/IO/lib/IO/Select.pm
index 994f8966ab..4d966418f9 100644
--- a/dist/IO/lib/IO/Select.pm
+++ b/dist/IO/lib/IO/Select.pm
@@ -11,7 +11,7 @@ use warnings::register;
 use vars qw($VERSION @ISA);
 require Exporter;
 
-$VERSION = "1.22";
+$VERSION = "1.23";
 
 @ISA = qw(Exporter); # This is only so we can do version checking
 
@@ -315,10 +315,13 @@ Return an array of all registered handles.
 
 =item can_read ( [ TIMEOUT ] )
 
-Return an array of handles that are ready for reading. C is
-the maximum amount of time to wait before returning an empty list, in
-seconds, possibly fractional. If C is not given and any
-handles are registered then the call will block.
+Return an array of handles that are ready for reading.  C is the
+maximum amount of time to wait before returning an empty list (with C<$!>
+unchanged), in seconds, possibly fractional.  If C is not given
+and any handles are registered then the call will block indefinitely.
+Upon error, an empty list is returned, with C<$!> set to indicate the
+error.  To distinguish between timeout and error, set C<$!> to zero
+before calling this method, and check it after an empty list is returned.
 
 =item can_write ( [ TIMEOUT ] )
 
@@ -346,9 +349,14 @@ like C. C, C and C are either 
C or
 C objects. C is optional and has the same effect as
 for the core select call.
 
-The result will be an array of 3 elements, each a reference to an array
-which will hold the handles that are ready for reading, writing and have
-exceptions respectively. Upon error an empty list is returned.
+If at least one handle is ready for the specified kind of operation,
+the result will be an array of 3 elements, each a reference to an array
+which will hold the handles that are ready for reading, writing and
+have exceptions respectively.  Upon timeout, an empty list is returned,
+with C<$!> unchanged.  Upon error, an empty list is returned, with C<$!>
+set to indicate the error.  To distinguish between timeout and error,
+set C<$!> to zero before calling this method, and check it after an
+empty list is returned.
 
 =back
 

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-327-g4efcdc0252

2017-11-11 Thread Lukas Mai
In perl.git, the branch blead has been updated



- Log -
commit 4efcdc0252c3ba1728081298180489b8772bc6d6
Author: Lukas Mai 
Date:   Sun Nov 12 02:58:32 2017 +0100

prevent invalid memory access in S_check_uni (RT #132433)

---

Summary of changes:
 t/comp/parser_run.t | 8 +++-
 toke.c  | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/t/comp/parser_run.t b/t/comp/parser_run.t
index eba4b9fba8..2408fcd2b4 100644
--- a/t/comp/parser_run.t
+++ b/t/comp/parser_run.t
@@ -10,7 +10,7 @@ BEGIN {
 set_up_inc( qw(. ../lib ) );
 }
 
-plan(4);
+plan(5);
 
 # [perl #130814] can reallocate lineptr while looking ahead for
 # "Missing $ on loop variable" diagnostic.
@@ -49,5 +49,11 @@ SKIP:
 is($out, "", "check for ASAN use after free");
 }
 
+fresh_perl_is('-C-', <<'EXPECTED', {}, "ambiguous unary operator check doesn't 
crash (#132433)");
+Warning: Use of "-C-" without parentheses is ambiguous at - line 1.
+syntax error at - line 1, at EOF
+Execution of - aborted due to compilation errors.
+EXPECTED
+
 __END__
 # ex: set ts=8 sts=4 sw=4 et:
diff --git a/toke.c b/toke.c
index c8ca63adbb..3dd4b47470 100644
--- a/toke.c
+++ b/toke.c
@@ -1935,7 +1935,7 @@ S_check_uni(pTHX)
 s = PL_last_uni;
 while (isWORDCHAR_lazy_if_safe(s, PL_bufend, UTF) || *s == '-')
s += UTF ? UTF8SKIP(s) : 1;
-if (memchr(s, '(', PL_bufptr - s))
+if (s < PL_bufptr && memchr(s, '(', PL_bufptr - s))
return;
 
 Perl_ck_warner_d(aTHX_ packWARN(WARN_AMBIGUOUS),

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-326-gd1ac83c401

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit d1ac83c4011b4bf51ca3fb070737a97a6c6ac545
Author: Daniel Dragan 
Date:   Sun Aug 16 04:30:23 2015 -0400

fix do dir returning no $!

do()ing a directory was returning false/empty string in $!, which isn't
an error, yet documentation says $! should have the error code in it.
Fix this by returning EISDIR for dirs, and EINVAL for block devices.
[perl #125774]

Remove "errno = 0" and comment added in b2da7ead68, since now there is no
scenario where errno is uninitialized, since the dir and block device
failure branches now set errno, where previously they didn't.

---

Summary of changes:
 pod/perldelta.pod |  5 +
 pp_ctl.c  | 25 +
 t/op/do.t | 14 +-
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 51953078c3..f292b52fe7 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -558,6 +558,11 @@ operator.  [perl #132245]
 Fixed a leaked SV when parsing an empty C<\N{}> at compile-time.
 [perl #132245]
 
+=item *
+
+Calling C on a directory or block device now yields a meaningful
+error code in C<$!>.  [perl #125774]
+
 =back
 
 =head1 Known Problems
diff --git a/pp_ctl.c b/pp_ctl.c
index a113b48db8..7581b37985 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3562,15 +3562,22 @@ S_check_type_and_open(pTHX_ SV *name)
errno EACCES, so only do a stat to separate a dir from a real EACCES
caused by user perms */
 #ifndef WIN32
-/* we use the value of errno later to see how stat() or open() failed.
- * We don't want it set if the stat succeeded but we still failed,
- * such as if the name exists, but is a directory */
-errno = 0;
-
 st_rc = PerlLIO_stat(p, );
 
-if (st_rc < 0 || S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) {
+if (st_rc < 0)
return NULL;
+else {
+   int eno;
+   if(S_ISBLK(st.st_mode)) {
+   eno = EINVAL;
+   goto not_file;
+   }
+   else if(S_ISDIR(st.st_mode)) {
+   eno = EISDIR;
+   not_file:
+   errno = eno;
+   return NULL;
+   }
 }
 #endif
 
@@ -3582,8 +3589,10 @@ S_check_type_and_open(pTHX_ SV *name)
int eno;
st_rc = PerlLIO_stat(p, );
if (st_rc >= 0) {
-   if(S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode))
-   eno = 0;
+   if(S_ISDIR(st.st_mode))
+   eno = EISDIR;
+   else if(S_ISBLK(st.st_mode))
+   eno = EINVAL;
else
eno = EACCES;
errno = eno;
diff --git a/t/op/do.t b/t/op/do.t
index 78d8800886..1c54f0b410 100644
--- a/t/op/do.t
+++ b/t/op/do.t
@@ -7,6 +7,7 @@ BEGIN {
 }
 use strict;
 no warnings 'void';
+use Errno qw(ENOENT EISDIR);
 
 my $called;
 my $result = do{ ++$called; 'value';};
@@ -247,7 +248,7 @@ SKIP: {
 my $saved_errno = $!;
 ok(!$rv,  "do returns false on io errror");
 ok(!$saved_error, "\$\@ not set on io error");
-ok($saved_errno,  "\$! set on io error");
+ok($saved_errno == ENOENT, "\$! is ENOENT for nonexistent file");
 }
 
 # do subname should not be do "subname"
@@ -305,4 +306,15 @@ SKIP: {
 }
 
 
+# do file $!s must be correct
+{
+local @INC = ('.'); #want EISDIR not ENOENT
+my $rv = do 'op'; # /t/op dir
+my $saved_error = $@;
+my $saved_errno = $!+0;
+ok(!$rv,"do dir returns false");
+ok(!$saved_error,   "\$\@ is false on do dir");
+ok($saved_errno == EISDIR,  "\$! is EISDIR on do dir");
+}
+
 done_testing();

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-325-g69374fe705

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 69374fe705978962b85217f3eb828a93f836fd8d
Author: Zefram 
Date:   Sat Nov 11 23:58:32 2017 +

avoid reading errno twice in a row

Reading errno can involve calling a function and indirecting through
its result, so cache the value of errno where possible.  [perl #122096]

---

Summary of changes:
 perl.c| 5 +++--
 win32/win32.c | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/perl.c b/perl.c
index bf48b31493..d50bac7cc4 100644
--- a/perl.c
+++ b/perl.c
@@ -5231,8 +5231,9 @@ Perl_my_failure_exit(pTHX)
 
 #else
 int exitstatus;
-if (errno & 255)
-   STATUS_UNIX_SET(errno);
+int eno = errno;
+if (eno & 255)
+   STATUS_UNIX_SET(eno);
 else {
exitstatus = STATUS_UNIX >> 8;
if (exitstatus & 255)
diff --git a/win32/win32.c b/win32/win32.c
index 89522abaca..c7656c631b 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -619,6 +619,7 @@ Perl_do_aspawn(pTHX_ SV *really, SV **mark, SV **sp)
 int status;
 int flag = P_WAIT;
 int index = 0;
+int eno;
 
 PERL_ARGS_ASSERT_DO_ASPAWN;
 
@@ -645,7 +646,7 @@ Perl_do_aspawn(pTHX_ SV *really, SV **mark, SV **sp)
   (const char*)(really ? SvPV_nolen(really) : argv[0]),
   (const char* const*)argv);
 
-if (status < 0 && (errno == ENOEXEC || errno == ENOENT)) {
+if (status < 0 && (eno = errno, (eno == ENOEXEC || eno == ENOENT))) {
/* possible shell-builtin, invoke with shell */
int sh_items;
sh_items = w32_perlshell_items;

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-323-g2b503742ec

2017-11-11 Thread Lukas Mai
In perl.git, the branch blead has been updated



- Log -
commit 2b503742ec83467c3ba4fb5b70583a4df2810a3e
Author: Lukas Mai 
Date:   Sat Nov 11 18:18:14 2017 +0100

teach makedef.pl about PL_keyword_plugin_mutex

This fixes t/porting/globvar.t.

---

Summary of changes:
 makedef.pl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/makedef.pl b/makedef.pl
index 1f44cc5780..5dc7bdf35c 100644
--- a/makedef.pl
+++ b/makedef.pl
@@ -358,6 +358,7 @@ unless ($define{'USE_ITHREADS'}) {
 
 unless ($define{'USE_ITHREADS'}) {
 ++$skip{$_} foreach qw(
+PL_keyword_plugin_mutex
PL_check_mutex
PL_op_mutex
PL_regex_pad

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-322-g7d65f652cb

2017-11-11 Thread Father Chrysostomos
In perl.git, the branch blead has been updated



- Log -
commit 7d65f652cb34981f4cb53a56496f5712f740d496
Author: Father Chrysostomos 
Date:   Fri Nov 10 13:57:33 2017 -0800

perldelta for reënabling of CV optimization

commit d96402565ccd7459d3a8bc4074f177d00bbefeeb
Author: Father Chrysostomos 
Date:   Sun Oct 29 11:21:45 2017 -0700

Revert "Temporarily revert CV-in-stash optimisation"

This reverts commit 6eed25e2537643b77650cb3e4514ec9dc2e97d74.

---

Summary of changes:
 op.c  |  2 +-
 pod/perldelta.pod | 24 
 t/op/sub.t|  1 -
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/op.c b/op.c
index c61bfd08de..368f9b146e 100644
--- a/op.c
+++ b/op.c
@@ -9617,7 +9617,7 @@ Perl_newATTRSUB_x(pTHX_ I32 floor, OP *o, OP *proto, OP 
*attrs,
   sub is stored in.  */
const I32 flags =
   ec ? GV_NOADD_NOINIT
- :   PL_curstash != CopSTASH(PL_curcop)
+ :   (IN_PERL_RUNTIME && PL_curstash != CopSTASH(PL_curcop))
   || memchr(name, ':', namlen) || memchr(name, '\'', namlen)
? gv_fetch_flags
: GV_ADDMULTI | GV_NOINIT | GV_NOTQUAL;
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index fbd5e9cacd..51953078c3 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -79,6 +79,24 @@ The parsing has now been made consistent, permitting 
yada-yada only as
 a statement.  Affected code can use C to put a yada-yada into
 an arbitrary expression context.
 
+=head2 Subroutines no longer need typeglobs
+
+Perl 5.22.0 introduced an optimization allowing subroutines to be stored in
+packages as simple sub refs, not requiring a full typeglob (thus
+potentially saving large amounts of memeory).  However, the optimization
+was flawed: it only applied to the main package.
+
+This optimization has now been extended to all packages.  This may break
+compatibility with introspection code that looks inside stashes and expects
+everything in them to be a typeglob.
+
+When this optimization happens, the typeglob still notionally exists, so
+accessing it will cause the stash entry to be upgraded to a typeglob.  The
+optimization does not apply to XSUBs or exported subroutines, and calling a
+method will undo it, since method calls cache things in typeglobs.
+
+[perl #129916] [perl #132252]
+
 =head1 Deprecations
 
 XXX Any deprecated features, syntax, modules etc. should be listed here.
@@ -155,6 +173,12 @@ In addition, C expressions which have a constant 
format
 containing only C<%s> and C<%%> format elements, and which have a fixed
 number of arguments, are now also optimised into a C op.
 
+=item *
+
+Subroutines in packages no longer need to be stored in typeglobs, saving
+large amounts of memory.  See L
+under L, above.
+
 =back
 
 =head1 Modules and Pragmata
diff --git a/t/op/sub.t b/t/op/sub.t
index 5c501b181e..f73abb455f 100644
--- a/t/op/sub.t
+++ b/t/op/sub.t
@@ -423,7 +423,6 @@ is ref($main::{rt_129916}), 'CODE', 'simple sub stored as 
CV in stash (main::)';
 sub foo { 42 }
 }
 {
-local $TODO = "CV symbol table optimization only works in main:: [perl 
#129916]";
 is ref($RT129916::{foo}), 'CODE', 'simple sub stored as CV in stash 
(non-main::)';
 }
 

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-320-g445198b9b5

2017-11-11 Thread Lukas Mai
In perl.git, the branch blead has been updated



- Log -
commit 445198b9b50e1018da1c98005a88bdf15c964f23
Author: Lukas Mai 
Date:   Sat Nov 11 13:35:13 2017 +0100

Revert "Simplify _MEM_WRAP_NEEDS_RUNTIME_CHECK()"

This reverts commit 004073bac990d90244eb463f435c52d4040b36df.

commit b7112dce7ec5b90ace89fcf4598b0be8168fea82
Author: Lukas Mai 
Date:   Sat Nov 11 13:34:20 2017 +0100

fix MEM_SIZE_MAX definition

---

Summary of changes:
 handy.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/handy.h b/handy.h
index f75c900656..77415ecb45 100644
--- a/handy.h
+++ b/handy.h
@@ -2295,7 +2295,7 @@ PoisonWith(0xEF) for catching access to freed memory.
 #define NEWSV(x,len)   newSV(len)
 #endif
 
-#define MEM_SIZE_MAX ((MEM_SIZE)~0)
+#define MEM_SIZE_MAX ((MEM_SIZE)-1)
 
 #define _PERL_STRLEN_ROUNDUP_UNCHECKED(n) (((n) - 1 + 
PERL_STRLEN_ROUNDUP_QUANTUM) & ~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM - 1))
 
@@ -2312,7 +2312,8 @@ PoisonWith(0xEF) for catching access to freed memory.
  */
 
 #  define _MEM_WRAP_NEEDS_RUNTIME_CHECK(n,t) \
-(8 * sizeof(n) + sizeof(t) > sizeof(MEM_SIZE))
+(  sizeof(MEM_SIZE) < sizeof(n) \
+|| sizeof(t) > ((MEM_SIZE)1 << 8*(sizeof(MEM_SIZE) - sizeof(n
 
 /* This is written in a slightly odd way to avoid various spurious
  * compiler warnings. We *want* to write the expression as

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-318-g2b8b74b077

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 2b8b74b0774fa605da54cf36ca3be953a4ef9703
Author: Zefram 
Date:   Sat Nov 11 12:44:49 2017 +

perldelta entry for perlguts revision

---

Summary of changes:
 pod/perldelta.pod | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 023b55ad45..fbd5e9cacd 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -255,6 +255,12 @@ to be considered variable length, and hence disallowed.
 
 =item *
 
+The section on reference counting in L has been heavily revised,
+to describe references in the way a programmer needs to think about them
+rather than in terms of the physical data structures.
+
+=item *
+
 XXX Description of the change here
 
 =back

-- 
Perl5 Master Repository


[perl.git] branch blead updated. v5.27.5-317-g3d2ba989c0

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit 3d2ba989c02b2154ab3673b3a376aa68edc2ed06
Author: Zefram 
Date:   Sat Nov 11 12:20:40 2017 +

better documentation of reference counts

---

Summary of changes:
 pod/perlguts.pod | 159 ++-
 1 file changed, 98 insertions(+), 61 deletions(-)

diff --git a/pod/perlguts.pod b/pod/perlguts.pod
index e90e9035e5..54a76dac45 100644
--- a/pod/perlguts.pod
+++ b/pod/perlguts.pod
@@ -798,68 +798,116 @@ Perl uses a reference count-driven garbage collection 
mechanism.  SVs,
 AVs, or HVs (xV for short in the following) start their life with a
 reference count of 1.  If the reference count of an xV ever drops to 0,
 then it will be destroyed and its memory made available for reuse.
-
-This normally doesn't happen at the Perl level unless a variable is
-undef'ed or the last variable holding a reference to it is changed or
-overwritten.  At the internal level, however, reference counts can be
-manipulated with the following macros:
+At the most basic internal level, reference counts can be manipulated
+with the following macros:
 
 int SvREFCNT(SV* sv);
 SV* SvREFCNT_inc(SV* sv);
 void SvREFCNT_dec(SV* sv);
 
-However, there is one other function which manipulates the reference
-count of its argument.  The C function, you will recall,
-creates a reference to the specified argument.  As a side effect,
-it increments the argument's reference count.  If this is not what
-you want, use C instead.
-
-For example, imagine you want to return a reference from an XSUB function.
-Inside the XSUB routine, you create an SV which initially has a reference
-count of one.  Then you call C, passing it the just-created SV.
-This returns the reference as a new SV, but the reference count of the
-SV you passed to C has been incremented to two.  Now you
-return the reference from the XSUB routine and forget about the SV.
-But Perl hasn't!  Whenever the returned reference is destroyed, the
-reference count of the original SV is decreased to one and nothing happens.
-The SV will hang around without any way to access it until Perl itself
-terminates.  This is a memory leak.
-
-The correct procedure, then, is to use C instead of
-C.  Then, if and when the last reference is destroyed,
-the reference count of the SV will go to zero and it will be destroyed,
-stopping any memory leak.
+(There are also suffixed versions of the increment and decrement macros,
+for situations where the full generality of these basic macros can be
+exchanged for some performance.)
+
+However, the way a programmer should think about references is not so
+much in terms of the bare reference count, but in terms of I
+of references.  A reference to an xV can be owned by any of a variety
+of entities: another xV, the Perl interpreter, an XS data structure,
+a piece of running code, or a dynamic scope.  An xV generally does not
+know what entities own the references to it; it only knows how many
+references there are, which is the reference count.
+
+To correctly maintain reference counts, it is essential to keep track
+of what references the XS code is manipulating.  The programmer should
+always know where a reference has come from and who owns it, and be
+aware of any creation or destruction of references, and any transfers
+of ownership.  Because ownership isn't represented explicitly in the xV
+data structures, only the reference count need be actually maintained
+by the code, and that means that this understanding of ownership is not
+actually evident in the code.  For example, transferring ownership of a
+reference from one owner to another doesn't change the reference count
+at all, so may be achieved with no actual code.  (The transferring code
+doesn't touch the referenced object, but does need to ensure that the
+former owner knows that it no longer owns the reference, and that the
+new owner knows that it now does.)
+
+An xV that is visible at the Perl level should not become unreferenced
+and thus be destroyed.  Normally, an object will only become unreferenced
+when it is no longer visible, often by the same means that makes it
+invisible.  For example, a Perl reference value (RV) owns a reference to
+its referent, so if the RV is overwritten that reference gets destroyed,
+and the no-longer-reachable referent may be destroyed as a result.
+
+Many functions have some kind of reference manipulation as
+part of their purpose.  Sometimes this is documented in terms
+of ownership of references, and sometimes it is (less helpfully)
+documented in terms of changes to reference counts.  For example, the
+L function is 

[perl.git] branch blead updated. v5.27.5-316-g6cc7638e57

2017-11-11 Thread Lukas Mai
In perl.git, the branch blead has been updated



- Log -
commit 6cc7638e57c54706dc2d698d9b2f9f769c17ffb4
Merge: a337154664 ee5287f665
Author: Lukas Mai 
Date:   Sat Nov 11 11:19:05 2017 +0100

Merge wrap_keyword_plugin() into blead

---

Summary of changes:
 MANIFEST  |  1 +
 dosish.h  |  7 +--
 embed.fnc |  1 +
 embed.h   |  1 +
 embedvar.h|  2 +
 ext/XS-APItest/APItest.xs |  4 +-
 ext/XS-APItest/t/keyword_plugin_threads.t | 32 ++
 perl.c|  1 +
 perl.h| 12 +
 perlapi.h |  2 +
 perlvars.h|  6 +++
 pod/perldelta.pod |  9 
 proto.h   |  3 ++
 toke.c| 73 +++
 unixish.h | 15 ---
 15 files changed, 157 insertions(+), 12 deletions(-)
 create mode 100644 ext/XS-APItest/t/keyword_plugin_threads.t

diff --git a/MANIFEST b/MANIFEST
index 7fcd227fae..7df52ed8c9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4325,6 +4325,7 @@ ext/XS-APItest/t/hash.t   XS::APItest: tests for 
hash related APIs
 ext/XS-APItest/t/join_with_space.t test op_convert_list
 ext/XS-APItest/t/keyword_multiline.t   test keyword plugin parsing across lines
 ext/XS-APItest/t/keyword_plugin.t  test keyword plugin mechanism
+ext/XS-APItest/t/keyword_plugin_threads.t  test keyword plugin loading 
from multiple threads
 ext/XS-APItest/t/labelconst.auxauxiliary file for label test
 ext/XS-APItest/t/labelconst.t  test recursive descent label parsing
 ext/XS-APItest/t/labelconst_utf8.aux   auxiliary file for label test in UTF-8
diff --git a/dosish.h b/dosish.h
index 9fd43ea682..16ee9b7359 100644
--- a/dosish.h
+++ b/dosish.h
@@ -48,9 +48,10 @@
 #endif
 
 #ifndef PERL_SYS_TERM_BODY
-#  define PERL_SYS_TERM_BODY()  \
-HINTS_REFCNT_TERM; OP_CHECK_MUTEX_TERM; \
-OP_REFCNT_TERM; PERLIO_TERM; MALLOC_TERM; LOCALE_TERM;
+#  define PERL_SYS_TERM_BODY() \
+HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM;  \
+OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; PERLIO_TERM;  \
+MALLOC_TERM; LOCALE_TERM;
 #endif
 #define dXSUB_SYS dNOOP
 
diff --git a/embed.fnc b/embed.fnc
index be12f88024..6269498ec7 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1185,6 +1185,7 @@ Apd   |void   |cv_set_call_checker_flags|NN CV *cv \
  |NN Perl_call_checker ckfun \
  |NN SV *ckobj|U32 ckflags
 Apd|void   |wrap_op_checker|Optype opcode|NN Perl_check_t new_checker|NN 
Perl_check_t *old_checker_p
+AMpd   |void   |wrap_keyword_plugin|NN Perl_keyword_plugin_t new_plugin|NN 
Perl_keyword_plugin_t *old_plugin_p
 ApR|PERL_SI*|new_stackinfo|I32 stitems|I32 cxitems
 Ap |char*  |scan_vstring   |NN const char *s|NN const char *const e \
|NN SV *sv
diff --git a/embed.h b/embed.h
index ea05c91343..46c59b5b4e 100644
--- a/embed.h
+++ b/embed.h
@@ -771,6 +771,7 @@
 #define whichsig_pv(a) Perl_whichsig_pv(aTHX_ a)
 #define whichsig_pvn(a,b)  Perl_whichsig_pvn(aTHX_ a,b)
 #define whichsig_sv(a) Perl_whichsig_sv(aTHX_ a)
+#define wrap_keyword_plugin(a,b)   Perl_wrap_keyword_plugin(aTHX_ a,b)
 #define wrap_op_checker(a,b,c) Perl_wrap_op_checker(aTHX_ a,b,c)
 #if !(defined(HAS_MEMMEM))
 #define ninstr Perl_ninstr
diff --git a/embedvar.h b/embedvar.h
index 898b71cd31..1a146c4d54 100644
--- a/embedvar.h
+++ b/embedvar.h
@@ -401,6 +401,8 @@
 #define PL_Ghints_mutex(my_vars->Ghints_mutex)
 #define PL_keyword_plugin  (my_vars->Gkeyword_plugin)
 #define PL_Gkeyword_plugin (my_vars->Gkeyword_plugin)
+#define PL_keyword_plugin_mutex(my_vars->Gkeyword_plugin_mutex)
+#define PL_Gkeyword_plugin_mutex   (my_vars->Gkeyword_plugin_mutex)
 #define PL_locale_mutex(my_vars->Glocale_mutex)
 #define PL_Glocale_mutex   (my_vars->Glocale_mutex)
 #define PL_malloc_mutex(my_vars->Gmalloc_mutex)
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs
index ffdc56c38e..8bf1545b63 100644
--- a/ext/XS-APItest/APItest.xs
+++ b/ext/XS-APItest/APItest.xs
@@ -1242,6 +1242,7 @@ static int my_keyword_plugin(pTHX_
*op_ptr = parse_join_with_space();
return KEYWORD_PLUGIN_EXPR;
 } else {
+assert(next_keyword_plugin != 

[perl.git] branch smoke-me/mauke/keyword-plugin-mutex updated. v5.27.5-315-gee5287f665

2017-11-11 Thread Lukas Mai
In perl.git, the branch smoke-me/mauke/keyword-plugin-mutex has been updated



  discards  9d94d96ddd7ffda5ae5a07dc333f3d6ea749fc1f (commit)
  discards  7185999f819582746b0c109cec891ef62350a3db (commit)
  discards  0060923148e8bcdeb77870b945cf37b69809b0d5 (commit)
- Log -
commit ee5287f6652fd59bd7925b1bdb88760225ddd2b6
Author: Lukas Mai 
Date:   Thu Nov 9 01:19:58 2017 +0100

perldelta entry for wrap_keyword_plugin

commit fbc25bdd99b5d54bd9f0cea98247aee2575354d8
Author: Lukas Mai 
Date:   Thu Nov 9 01:00:23 2017 +0100

test wrap_keyword_plugin (RT #132413)

commit 1e5c5f69249acd964e640650e65901f390085022
Author: Lukas Mai 
Date:   Thu Nov 9 00:59:53 2017 +0100

add wrap_keyword_plugin function (RT #132413)

---

Summary of changes:
 .gitignore | 1 +
 .travis.yml| 7 +-
 MANIFEST   | 5 +
 PACKAGING  | 9 +
 Porting/Maintainers.pl | 2 +-
 Porting/Maintainers.pm | 9 +-
 Porting/pod_rules.pl   | 2 +-
 av.c   |20 +-
 configpm   | 6 +-
 cpan/Unicode-Collate/Collate.pm|23 +-
 cpan/Unicode-Collate/Collate.xs|21 +-
 cpan/Unicode-Collate/Collate/CJK/Big5.pm   | 2 +-
 cpan/Unicode-Collate/Collate/CJK/GB2312.pm | 2 +-
 cpan/Unicode-Collate/Collate/CJK/JISX0208.pm   | 2 +-
 cpan/Unicode-Collate/Collate/CJK/Korean.pm |26 +-
 cpan/Unicode-Collate/Collate/CJK/Pinyin.pm | 2 +-
 cpan/Unicode-Collate/Collate/CJK/Stroke.pm | 2 +-
 cpan/Unicode-Collate/Collate/CJK/Zhuyin.pm | 2 +-
 cpan/Unicode-Collate/Collate/Locale.pm |58 +-
 cpan/Unicode-Collate/Collate/Locale/af.pl  | 6 +-
 cpan/Unicode-Collate/Collate/Locale/ar.pl  |24 +-
 cpan/Unicode-Collate/Collate/Locale/as.pl  |22 +-
 cpan/Unicode-Collate/Collate/Locale/az.pl  |98 +-
 cpan/Unicode-Collate/Collate/Locale/be.pl  |20 +-
 cpan/Unicode-Collate/Collate/Locale/bn.pl  |12 +-
 cpan/Unicode-Collate/Collate/Locale/ca.pl  |28 +-
 cpan/Unicode-Collate/Collate/Locale/cs.pl  |44 +-
 cpan/Unicode-Collate/Collate/Locale/cy.pl  |52 +-
 cpan/Unicode-Collate/Collate/Locale/da.pl  |   148 +-
 cpan/Unicode-Collate/Collate/Locale/de_at_ph.pl|56 +-
 cpan/Unicode-Collate/Collate/Locale/de_phone.pl|52 +-
 cpan/Unicode-Collate/Collate/Locale/dsb.pl |59 +
 cpan/Unicode-Collate/Collate/Locale/ee.pl  |62 +-
 cpan/Unicode-Collate/Collate/Locale/eo.pl  |52 +-
 cpan/Unicode-Collate/Collate/Locale/es.pl  |12 +-
 cpan/Unicode-Collate/Collate/Locale/es_trad.pl |24 +-
 cpan/Unicode-Collate/Collate/Locale/et.pl  |96 +-
 cpan/Unicode-Collate/Collate/Locale/fa.pl  |88 +-
 cpan/Unicode-Collate/Collate/Locale/fi.pl  |   122 +-
 cpan/Unicode-Collate/Collate/Locale/fi_phone.pl|   118 +-
 cpan/Unicode-Collate/Collate/Locale/fil.pl |18 +-
 cpan/Unicode-Collate/Collate/Locale/fo.pl  |   148 +-
 cpan/Unicode-Collate/Collate/Locale/fr_ca.pl   | 2 +-
 cpan/Unicode-Collate/Collate/Locale/gu.pl  |12 +-
 cpan/Unicode-Collate/Collate/Locale/ha.pl  |24 +-
 cpan/Unicode-Collate/Collate/Locale/haw.pl |38 +-
 cpan/Unicode-Collate/Collate/Locale/he.pl  | 8 +-
 cpan/Unicode-Collate/Collate/Locale/hi.pl  |12 +-
 cpan/Unicode-Collate/Collate/Locale/hr.pl  |90 +-
 cpan/Unicode-Collate/Collate/Locale/hu.pl  |   296 +-
 cpan/Unicode-Collate/Collate/Locale/hy.pl  |12 +-
 cpan/Unicode-Collate/Collate/Locale/ig.pl  |   102 +-
 cpan/Unicode-Collate/Collate/Locale/is.pl  |   156 +-
 cpan/Unicode-Collate/Collate/Locale/ja.pl  |  2650 +-
 cpan/Unicode-Collate/Collate/Locale/kk.pl  |20 +-
 cpan/Unicode-Collate/Collate/Locale/kl.pl  |   144 +-
 cpan/Unicode-Collate/Collate/Locale/kn.pl  |14 +-
 cpan/Unicode-Collate/Collate/Locale/ko.pl  |  1284 +-
 cpan/Unicode-Collate/Collate/Locale/kok.pl |20 +-
 cpan/Unicode-Collate/Collate/Locale/lkt.pl |25 +
 cpan/Unicode-Collate/Collate/Locale/ln.pl  |18 +-
 cpan/Unicode-Collate/Collate/Locale/lt.pl  |82 +-
 

[perl.git] branch blead updated. v5.27.5-312-ga337154664

2017-11-11 Thread Zefram
In perl.git, the branch blead has been updated



- Log -
commit a3371546646b4c0f722f2659beac614649d6cfd5
Author: Zefram 
Date:   Sat Nov 11 10:05:53 2017 +

avoid runtime module loading in File::Spec

Incidentally remove the ->_cwd method from the subclassing interface of
File::Spec::Unix, in favour of direct calls to Cwd::getcwd().

---

Summary of changes:
 dist/PathTools/Changes|  4 
 dist/PathTools/lib/File/Spec/Mac.pm   |  5 +++--
 dist/PathTools/lib/File/Spec/OS2.pm   | 10 +++---
 dist/PathTools/lib/File/Spec/Unix.pm  | 31 ---
 dist/PathTools/lib/File/Spec/VMS.pm   |  5 +++--
 dist/PathTools/lib/File/Spec/Win32.pm |  6 +++---
 dist/PathTools/t/Spec.t   | 16 +++-
 7 files changed, 31 insertions(+), 46 deletions(-)

diff --git a/dist/PathTools/Changes b/dist/PathTools/Changes
index b145794357..c2ee7c1f6c 100644
--- a/dist/PathTools/Changes
+++ b/dist/PathTools/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl distribution PathTools.
 
+3.69
+- avoid loading modules repeatedly at runtime
+- replace 'use vars' by 'our'
+
 3.68
 - avoid warning from pre-5.8 code for detecting tainted values
 - make taint.t detect that a pre-5.8 Perl supports tainting
diff --git a/dist/PathTools/lib/File/Spec/Mac.pm 
b/dist/PathTools/lib/File/Spec/Mac.pm
index 082b9b8e80..345a829428 100644
--- a/dist/PathTools/lib/File/Spec/Mac.pm
+++ b/dist/PathTools/lib/File/Spec/Mac.pm
@@ -1,6 +1,7 @@
 package File::Spec::Mac;
 
 use strict;
+use Cwd ();
 require File::Spec::Unix;
 
 our $VERSION = '3.69';
@@ -668,7 +669,7 @@ sub abs2rel {
 
 # Figure out the effective $base and clean it up.
 if ( !defined( $base ) || $base eq '' ) {
-   $base = $self->_cwd();
+   $base = Cwd::getcwd();
 }
 elsif ( ! $self->file_name_is_absolute( $base ) ) {
 $base = $self->rel2abs( $base ) ;
@@ -736,7 +737,7 @@ sub rel2abs {
 if ( ! $self->file_name_is_absolute($path) ) {
 # Figure out the effective $base and clean it up.
 if ( !defined( $base ) || $base eq '' ) {
-   $base = $self->_cwd();
+   $base = Cwd::getcwd();
 }
 elsif ( ! $self->file_name_is_absolute($base) ) {
 $base = $self->rel2abs($base) ;
diff --git a/dist/PathTools/lib/File/Spec/OS2.pm 
b/dist/PathTools/lib/File/Spec/OS2.pm
index b126c279c2..6af4bf1d64 100644
--- a/dist/PathTools/lib/File/Spec/OS2.pm
+++ b/dist/PathTools/lib/File/Spec/OS2.pm
@@ -1,6 +1,7 @@
 package File::Spec::OS2;
 
 use strict;
+use Cwd ();
 require File::Spec::Unix;
 
 our $VERSION = '3.69';
@@ -29,11 +30,6 @@ sub path {
 return @path;
 }
 
-sub _cwd {
-# In OS/2 the "require Cwd" is unnecessary bloat.
-return Cwd::sys_cwd();
-}
-
 sub tmpdir {
 my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TEMP TMP');
 return $cached if defined $cached;
@@ -147,7 +143,7 @@ sub abs2rel {
 
 # Figure out the effective $base and clean it up.
 if ( !defined( $base ) || $base eq '' ) {
-   $base = $self->_cwd();
+   $base = Cwd::getcwd();
 } elsif ( ! $self->file_name_is_absolute( $base ) ) {
 $base = $self->rel2abs( $base ) ;
 } else {
@@ -204,7 +200,7 @@ sub rel2abs {
 if ( ! $self->file_name_is_absolute( $path ) ) {
 
 if ( !defined( $base ) || $base eq '' ) {
-   $base = $self->_cwd();
+   $base = Cwd::getcwd();
 }
 elsif ( ! $self->file_name_is_absolute( $base ) ) {
 $base = $self->rel2abs( $base ) ;
diff --git a/dist/PathTools/lib/File/Spec/Unix.pm 
b/dist/PathTools/lib/File/Spec/Unix.pm
index eecd8c80fc..f5ffdac86c 100644
--- a/dist/PathTools/lib/File/Spec/Unix.pm
+++ b/dist/PathTools/lib/File/Spec/Unix.pm
@@ -1,25 +1,11 @@
 package File::Spec::Unix;
 
 use strict;
+use Cwd ();
 
 our $VERSION = '3.69';
-my $xs_version = $VERSION;
 $VERSION =~ tr/_//d;
 
-#dont try to load XSLoader and DynaLoader only to ultimately fail on miniperl
-if(!defined  && defined ::boot_DynaLoader) {
-  eval {#eval is questionable since we are handling potential errors like
-#"Cwd object version 3.48 does not match bootstrap parameter 3.50
-#at lib/DynaLoader.pm line 216." by having this eval
-if ( $] >= 5.006 ) {
-   require XSLoader;
-   XSLoader::load("Cwd", $xs_version);
-} else {
-   require Cwd;
-}
-  };
-}
-
 =head1 NAME
 
 File::Spec::Unix - File::Spec for Unix, base for other File::Spec modules
@@ -409,7 +395,7 @@ Based on code written by Shigio Yamaguchi.
 
 sub abs2rel {
 my($self,$path,$base) = @_;
-$base = $self->_cwd() unless defined $base and length $base;
+$base = Cwd::getcwd() unless defined $base and length