This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
5 years agoPATCH: [perl #133876] Write out of bounds
Karl Williamson [Fri, 8 Mar 2019 17:01:48 +0000 (10:01 -0700)]
PATCH: [perl #133876] Write out of bounds

This was caused by a lapse on my part about the inputs to this function
that grows memory.  I was thinking the trailing NUL was included, but
it's not.  This patch adds space for that to all calls of
sv_utf8_upgrade_flags_grow() in the file.

But it occurs to me that maybe the function itself should just add one
instead of having the caller do it.  If you think so, let me know.

5 years agoperldelta for d22170b0f355 through bf3e41ff5d42
Tony Cook [Fri, 8 Mar 2019 00:08:53 +0000 (11:08 +1100)]
perldelta for d22170b0f355 through bf3e41ff5d42

5 years ago(perl #124203) fix a similar problem with DB::lsub
Tony Cook [Thu, 28 Feb 2019 00:53:19 +0000 (11:53 +1100)]
(perl #124203) fix a similar problem with DB::lsub

5 years agobump $DB::VERSION for perl5db.pl to 1.55
Tony Cook [Wed, 27 Feb 2019 04:29:23 +0000 (15:29 +1100)]
bump $DB::VERSION for perl5db.pl to 1.55

5 years agobump $threads::shared::VERSION to 1.60
Tony Cook [Wed, 27 Feb 2019 04:28:37 +0000 (15:28 +1100)]
bump $threads::shared::VERSION to 1.60

5 years ago(perl #124203) avoid a deadlock in DB::sub
Tony Cook [Wed, 27 Feb 2019 01:01:40 +0000 (12:01 +1100)]
(perl #124203) avoid a deadlock in DB::sub

I don't know how this ever worked.

Previously, DB::sub() would hold a lock on $DB::DBGR for it's entire
body, including the call to the subroutine being called.

This could cause problems in two cases:

a) on creation of a new thread, CLONE() is called in the context of
the new interpreter before the new thread is created.  So you'd have a
sequence like:

  threads->new
  DB::sub for threads::new (lock $DBGR)
  call into threads::new which creates a new interpreter
  Cwd::CLONE() (in the new interpreter)
  DB::sub for Cwd::CLONE (in the new interpreter) (deadlock trying to lock $DBGR)

One workaround I tried for this was to prevent pp_entersub calling
DB::sub if we were cloning (by checking PL_ptr_table).  This did
improve matters, but wasn't needed in the final patch.

Note that the recursive lock on $DBGR would have been fine if the new
code was executing in the same interpreter, since the locking code
simply bumps a reference count if the current interpreter already
holds the lock.

b) when the called subroutine blocks.  For the test case this could
happen with the call to $thr->join.  There would be a sequence like:

  (parent) $thr->join
  (parent) DB::sub for threads::join (lock $DBGR)
  (parent) call threads::join and block
  (child) try to call main::sub1
  (child) DB::sub for main::sub1 (deadlock trying to lock $DBGR)

This isn't limited to threads::join obviously, one thread could be
waiting for input, sleeping, or performing a complex calculation.

The solution I chose here was the obvious one - don't hold the lock
for the actual call.

This required some rearrangement of the code and removed some
duplication too.

5 years agoadd extra lock tracing to threads::shared
Tony Cook [Wed, 27 Feb 2019 01:01:12 +0000 (12:01 +1100)]
add extra lock tracing to threads::shared

This was useful in tracing the cause for the deadlock in #124203.

This can be enabled during a build of perl by adding:

  -Accflags=-DSHARED_TRACE_LOCKS -DDEBUGGING

to the Configure command-line.

To see the trace at run-time add -DU or -DUv to the perl command-line.

The original DEBUG_LOCKS tracing using warn caused extra calls
confusing back traces when trying to debug this problem.

5 years agoPATCH: [perl #133882] Assertion failure
Karl Williamson [Thu, 7 Mar 2019 20:44:34 +0000 (13:44 -0700)]
PATCH: [perl #133882] Assertion failure

The asserts in this routine were doing there job.  It was called
inappropriately, with len set to 0, which means for it that it's
supposed to calculate the length by using strlen().  But, len being 0
here meant that the input was empty.  When run under valgrind, errors
would also show up.

This function was being called to see if the string had any characters
that varied depending on if it is UTF-8 or not.  Since we know that the
answer is no if the length is 0, we simply don't call this function
then.

5 years agot/re/subst.t: Fix typo in comment
Karl Williamson [Thu, 7 Mar 2019 20:44:14 +0000 (13:44 -0700)]
t/re/subst.t: Fix typo in comment

5 years agoregexec.c: Rule out match sooner
Karl Williamson [Thu, 7 Mar 2019 18:40:25 +0000 (11:40 -0700)]
regexec.c: Rule out match sooner

If this function is passed a regnode that won't match a non-UTF-8
string, we can fail immediately if the string isn't UTF-8.

5 years agoregexec.c: Improve comments for a function
Karl Williamson [Thu, 7 Mar 2019 18:39:49 +0000 (11:39 -0700)]
regexec.c: Improve comments for a function

5 years agoPATCH: [perl #133899] panic in s///
Karl Williamson [Thu, 7 Mar 2019 18:37:21 +0000 (11:37 -0700)]
PATCH: [perl #133899] panic in s///

Thanks for finding this bug, and the others you've been finding.

A new regnode was added, but this function was not updated to account
for that.  I've now checked all the other new regnodes in 5.29 and this
was the only missing one.

5 years agoAdd hook for Unicode private use override
Karl Williamson [Thu, 7 Mar 2019 00:50:23 +0000 (17:50 -0700)]
Add hook for Unicode private use override

I am starting to write a Unicode::Private_Use module which will allow
one to specify the Unicode properties of private use code points, thus
making them actually useful.  This commit adds a hook to regcomp.c to
accommodate this module.  The changes are pretty minimal.  This way we
don't have to wait another release cycle to get it out there.

I don't want to document this interface, until it's proven.

5 years agofix CvFILE() leak in Perl_newATTRSUB_x()
David Mitchell [Thu, 7 Mar 2019 10:23:04 +0000 (10:23 +0000)]
fix CvFILE() leak in Perl_newATTRSUB_x()

When overwriting cv with the contents of PL_compcv, it was checking the
CvDYNFILE(cv) flag (to see if CvFILE(cv) needed freeing) *after*
overwriting cv's flags with PL_compcv's flag.

5 years agoImprove description of CVf_DYNFILE flag
David Mitchell [Thu, 7 Mar 2019 10:21:25 +0000 (10:21 +0000)]
Improve description of CVf_DYNFILE flag

5 years agoadd comments above Perl_newSTUB()
David Mitchell [Thu, 7 Mar 2019 08:42:59 +0000 (08:42 +0000)]
add comments above Perl_newSTUB()

5 years agofix leak in regex re-entrant capture buffer
David Mitchell [Wed, 6 Mar 2019 16:13:45 +0000 (16:13 +0000)]
fix leak in regex re-entrant capture buffer

When a regex is about to be executed, if it is the same regex as
PL_curpm, then its 'offs' capture-indices buffer is saved in a local var
pointer and a new one allocated. At the end of execution, depending on
success or failure, the old buffer is restored and the new freed, or
vice versa.

However, if the regex dies during execution, e.g. /(?{ die })/
then the old buffer will leak.

So use SAVEFREEPV() on the old buffer, and change the 'restore on
failure' behaviour - always free the old buffer and keep the new
buffer, and instead copy the old indices to the new buffer.

5 years agofix leak in /[(?{]/
David Mitchell [Wed, 6 Mar 2019 10:36:23 +0000 (10:36 +0000)]
fix leak in /[(?{]/

This pattern is correctly interpreted by the parser as not containing
any code blocks, e.g. (?{...}). It's then passed to the regex compiler,
which thinks it may after all contain a code block not seen before (e.g.
interpolated in at runtime). So it evals the code qr'[(?{]' to compile
any code blocks.  Again the parser doesn't see any code blocks, so the
regex compiler realises it was wrong, and attempts to free the hidden
anon CV associated with compiling a qr// (this CV would take ownership
of any found code blocks, but is empty apart from a single OP_CONST
containing the text of regex).

This freeing of the CV was going wrong, resulting in the op slab(s)
associated with the anon CV leaking.

This was because cv_forget_slab(PL_compcv) was being called, which
converts a compiling CV into a compiled  CV, where CvSTART() no longer
points to the op slab, and instead the slab can only be accessed
indirectly via the ops in CvROOT().

Then when the CV is freed, because it is no longer marked as SvSLABBED,
the freeing code assumes that any associated ops are attached via
SvROOT() - but they haven't been yet - they're still sitting on the
yyparse stack. So they leak.

The solution seems to be a simple as removing the call to
cv_forget_slab().

I sort of understood this as I wrote this commit message, but it's
fading already. Don't ask me to explain this in a week's time, let alone
next year.

5 years agodocs for op slab functions
David Mitchell [Tue, 5 Mar 2019 10:24:30 +0000 (10:24 +0000)]
docs for op slab functions

Add some basic code comments at the top of each function associated
with allocating and freeing OP slabs.

5 years agoCheck for \n in EBCDIC code pages
Karl Williamson [Wed, 6 Mar 2019 21:00:10 +0000 (14:00 -0700)]
Check for \n in EBCDIC code pages

IBM says that there are 13 characters whose code point varies depending
on the EBCDIC code page.  They fail to mention that the \n character may
also vary.  This commit adds checks for \n, in addition to the checks
for the 13 graphic variant ones.

5 years agodocs (incl. perldelta) for aa8a2baafac
Karl Williamson [Wed, 6 Mar 2019 21:22:22 +0000 (14:22 -0700)]
docs (incl. perldelta) for aa8a2baafac

5 years agoUse POSIX locale functions if setlocale not available
Karl Williamson [Mon, 4 Mar 2019 21:00:41 +0000 (14:00 -0700)]
Use POSIX locale functions if setlocale not available

POSIX 2008 added an independent set of locale handling functions beyond
the venerable setlocale.  This commit changes so they can be used rather
than have no locale handling if there is, say, a problem with setlocale.

5 years agoperldelta for Unicode 12.0
Karl Williamson [Mon, 4 Mar 2019 23:15:39 +0000 (16:15 -0700)]
perldelta for Unicode 12.0

5 years agoUse Unicode 12.0
Unicode Consortium [Mon, 4 Mar 2019 23:08:22 +0000 (16:08 -0700)]
Use Unicode 12.0

Unicode 12.0 is finalized.  Change to use it.

5 years agoMerge branch 'crippled_locales' into blead
Karl Williamson [Mon, 4 Mar 2019 20:03:02 +0000 (13:03 -0700)]
Merge branch 'crippled_locales' into blead

This adds Configure probes to find platforms that have crippled locale
implementations, in which they pretend that they allow for locales, but
really don't.  Then use these probe results to inform our locale
handling; otherwise our locale tests on such systems would otherwise
fail.

5 years agoProperly handle systems with crippled locales
Karl Williamson [Mon, 4 Mar 2019 19:27:59 +0000 (12:27 -0700)]
Properly handle systems with crippled locales

Some systems fake their locales, so that they pretend to accept a locale
change, but they either do nothing, making everything the C locale, or
on some systems there is a a second locale "C-UTF-8" that can be
switched to.  Configure probes have been added to find such systems, and
this commit changes to use the results of these probes, so that we don't
try looking for other locales (any names we came up with would be
accepted as valid, but don't work, and tests were failing as a result).

Anything running the musl library fits, as does OpenBSD and its kin, as
they view locales as security risks.  This commit allows us to take out
some code that was looking for particular OS's.

5 years agot/loc_tools.pl: Only try C.UTF-8 if Configure says avail
Karl Williamson [Mon, 4 Mar 2019 18:56:05 +0000 (11:56 -0700)]
t/loc_tools.pl: Only try C.UTF-8 if Configure says avail

I added a Configure probe for this capability, since some platforms will
say yes to any locale name, so we can't really test for it in perl.

5 years agolocale.c: Tighten turkish locale tests on C99 platforms
Karl Williamson [Sun, 17 Feb 2019 05:01:44 +0000 (22:01 -0700)]
locale.c: Tighten turkish locale tests on C99 platforms

C99 has wide character case changing.  If those are available, use them
to be surer we have a Turkic locale.

5 years agoImprove setlocale() detection in Configure-ish files
Karl Williamson [Sun, 17 Feb 2019 05:12:41 +0000 (22:12 -0700)]
Improve setlocale() detection in Configure-ish files

This also now notes some behavior of setlocale

5 years agoAdd towupper() and towlower() to Configure-ish files
Karl Williamson [Sun, 17 Feb 2019 04:55:12 +0000 (21:55 -0700)]
Add towupper() and towlower() to Configure-ish files

5 years agoAdd wctype.h to Configure-ish files
Karl Williamson [Sun, 17 Feb 2019 04:31:29 +0000 (21:31 -0700)]
Add wctype.h to Configure-ish files

5 years agoperl.h: Improve a comment's wording
Karl Williamson [Mon, 4 Mar 2019 18:43:37 +0000 (11:43 -0700)]
perl.h: Improve a comment's wording

5 years agoregcomp.c: Silence compiler warning msg.
Karl Williamson [Mon, 4 Mar 2019 18:28:13 +0000 (11:28 -0700)]
regcomp.c: Silence compiler warning msg.

Some compilers aren't smart enough to realize there is no path through
this function that doesn't set the return value.  So initialize to an
illegal value.

Spotted by atoomic

5 years agolocale.c: Fix grammar in comment
Karl Williamson [Mon, 4 Mar 2019 18:26:04 +0000 (11:26 -0700)]
locale.c: Fix grammar in comment

5 years agolib/locale.t: Improve wording of test name
Karl Williamson [Mon, 4 Mar 2019 18:25:22 +0000 (11:25 -0700)]
lib/locale.t: Improve wording of test name

5 years agoperlop: Improve documentation for (mostly) tr///
Karl Williamson [Tue, 19 Feb 2019 00:57:11 +0000 (17:57 -0700)]
perlop: Improve documentation for (mostly) tr///

This adds examples and clarifications

5 years agoebcdic_tables.h: Remove alien '#'
Karl Williamson [Mon, 4 Mar 2019 17:30:38 +0000 (10:30 -0700)]
ebcdic_tables.h: Remove alien '#'

These were introduced in c05125c57fd7868af65366bacb6fe40c04b1c719 in
July 2018, and would cause any EBCDIC compilations to fail.

That I found it by code inspection shows that we've lost all our EBCDIC
smokers again.

5 years agoregen/ebcdic.pl: Move code to function
Karl Williamson [Mon, 4 Mar 2019 17:20:35 +0000 (10:20 -0700)]
regen/ebcdic.pl: Move code to function

This is for eventual use in being called from more than one place.

5 years agoFix dup_warnings()
Karl Williamson [Wed, 27 Feb 2019 22:09:07 +0000 (15:09 -0700)]
Fix dup_warnings()

It turns out that some Configure options cause this to be called with a
NULL parameter. (I didn't check, but my guess is it's threaded builds.)
That means that the embed.fnc entry should be NULLOK for the parameter.
And that means that embed.fnc doesn't generate an ARGS_ASSERT macro, so
that should be removed from the function.

(I actually think it should generate an empty ARGS_ASSERT that could be
included or not, so that code wouldn't have to change if a parameter
became required to be non-null or vice versa.  The porting test would
only check for non-empty macros being present.  But this is for another
day.)

The reason it works as-was with a NULL parameter is because of an
apparent coincidence: specialWARN() is called first thing in this
function and thinks a NULL is a defined marker for a particular meaning,
so the function immediately returns.  This commit makes that explicit
rather than relying on the apparent coincidence.

5 years agoAdd missing ARGS_ASSERT
Karl Williamson [Wed, 27 Feb 2019 16:28:05 +0000 (09:28 -0700)]
Add missing ARGS_ASSERT

From c1e47bad34ce1d9c84ed57c9b8978bcbd5a02e98

5 years agoadd Perl_dup_warnings() and fix leak
David Mitchell [Mon, 25 Feb 2019 13:05:04 +0000 (13:05 +0000)]
add Perl_dup_warnings() and fix leak

The macro DUP_WARNINGS() was doing (approximately)

    new = CopyD(old, malloc(size), size);

which, depending on how the CopyD macro expanded (e.g. on debugging
builds), could result in its arguments being used multiple times, and
thus malloc() being called multiple times, with the result of the
earlier call(s) then leaking.

Fix this by implementing DUP_WARNINGS using a new function,
Perl_dup_warnings() that stores its intermediate values in local vars.

This function isn't performance critical, as its usually only called
once per cop creation at compile time.

5 years agot/re/pat.t: avoid failing test under ASan
David Mitchell [Sun, 24 Feb 2019 12:53:20 +0000 (12:53 +0000)]
t/re/pat.t: avoid failing test under ASan

5 years agoperldelta for 7d0a46b7159e
Tony Cook [Mon, 25 Feb 2019 00:52:24 +0000 (11:52 +1100)]
perldelta for 7d0a46b7159e

5 years agobump $PerlIO::encoding::VERSION
Tony Cook [Mon, 25 Feb 2019 00:40:14 +0000 (11:40 +1100)]
bump $PerlIO::encoding::VERSION

5 years ago(perl #131683) enable warnings for the block that tests for warnings
Tony Cook [Mon, 25 Feb 2019 00:00:35 +0000 (11:00 +1100)]
(perl #131683) enable warnings for the block that tests for warnings

5 years agoPerlIO::encoding: Use Encode::ONLY_PRAGMA_WARNINGS in fallback by default
Pali [Sat, 1 Jul 2017 10:34:25 +0000 (12:34 +0200)]
PerlIO::encoding: Use Encode::ONLY_PRAGMA_WARNINGS in fallback by default

This would enable to respect utf8 warnings enabled/disabled by pramga
warnings when processing filehandle with :encoding layer.

5 years agoperldelta for 238f2c136aa0
Tony Cook [Sun, 24 Feb 2019 23:41:09 +0000 (10:41 +1100)]
perldelta for 238f2c136aa0

5 years agoAdd newSVsv_nomg() macro which is like newSVsv() but does not process get magic
Pali [Thu, 7 Feb 2019 13:10:35 +0000 (14:10 +0100)]
Add newSVsv_nomg() macro which is like newSVsv() but does not process get magic

Both newSVsv() and newSVsv_nomg() are now implemented via new Perl_newSVsv_flags() function.

5 years agoupgrade cpan/JSON-PP from 4.00 to 4.02
David Mitchell [Sat, 23 Feb 2019 12:27:17 +0000 (12:27 +0000)]
upgrade cpan/JSON-PP from 4.00 to 4.02

4.02 2019-02-23
    - fix a test that breaks if perl is compiled with
      -Dquadmath (RT-128589)

4.01 2019-02-22
    - allow to pass indent_length to json_pp (GH#46)

5 years agoPerl_op_sibling_splice(0 remove dead code
David Mitchell [Fri, 22 Feb 2019 10:59:23 +0000 (10:59 +0000)]
Perl_op_sibling_splice(0 remove dead code

Spotted by Coverity.

We've already checkerd earlier on that at least one of parent and start
is non-null, so the line in question can never be reached. Turn it into
an assertion instead.

5 years agoEpigraph for 5.29.8
Nicolas R [Thu, 21 Feb 2019 22:27:02 +0000 (15:27 -0700)]
Epigraph for 5.29.8

5 years agothey seek him here, they seek him there
Chris 'BinGOs' Williams [Thu, 21 Feb 2019 11:11:58 +0000 (11:11 +0000)]
they seek him here, they seek him there

5 years agofix for Module/CoreList.pm 5.029009
Nicolas R [Thu, 21 Feb 2019 06:34:27 +0000 (23:34 -0700)]
fix for Module/CoreList.pm 5.029009

damn it Nico..

5 years agoUpdate Module::CoreList for 5.29.9
Nicolas R [Thu, 21 Feb 2019 06:18:33 +0000 (23:18 -0700)]
Update Module::CoreList for 5.29.9

5 years agoBump the perl version in various places for 5.29.9
Nicolas R [Thu, 21 Feb 2019 06:11:11 +0000 (23:11 -0700)]
Bump the perl version in various places for 5.29.9

5 years agoNew perldelta for 5.29.9
Nicolas R [Thu, 21 Feb 2019 06:04:45 +0000 (23:04 -0700)]
New perldelta for 5.29.9

5 years agoTick! 5.29.8
Nicolas R [Thu, 21 Feb 2019 06:01:27 +0000 (23:01 -0700)]
Tick! 5.29.8

5 years agoExtra advice to release_managers_guide.pod
Nicolas R [Thu, 21 Feb 2019 05:11:03 +0000 (22:11 -0700)]
Extra advice to release_managers_guide.pod

5 years ago(perl #133778) adjust MARK if we extend the stack in pp_repeat
Tony Cook [Tue, 5 Feb 2019 23:37:58 +0000 (10:37 +1100)]
(perl #133778) adjust MARK if we extend the stack in pp_repeat

for a list repeat in scalar/void context

5 years agoBump Devel::PPPort to 3.44 for CPAN release v5.29.8
Nicolas R [Wed, 20 Feb 2019 23:15:28 +0000 (16:15 -0700)]
Bump Devel::PPPort to 3.44 for CPAN release

During v5.29.8 dev cycle a change was made to Devel-PPPort
18d728ac3b which justify to bump and release a new
version of Devel::PPPort.

5 years agoAdd 5.29.8 release to pod/perlhist
Nicolas R [Wed, 20 Feb 2019 20:58:44 +0000 (13:58 -0700)]
Add 5.29.8 release to pod/perlhist

5 years agoAdd XS::APItest to unclaimedModules in corelist-perldelta.pl
Nicolas R [Wed, 20 Feb 2019 19:23:50 +0000 (12:23 -0700)]
Add XS::APItest to unclaimedModules in corelist-perldelta.pl

Without this change corelist-perldelta.pl would not see the
changes from XS::APItest.

    ./perl -Ilib Porting/corelist-perldelta.pl \
        --mode=update pod/perldelta.pod

5 years agoUpdate Module::CoreList for 5.19.8
Nicolas R [Wed, 20 Feb 2019 18:34:52 +0000 (11:34 -0700)]
Update Module::CoreList for 5.19.8

5 years agoPerldelta final massage for 5.29.8 release
Nicolas R [Wed, 20 Feb 2019 17:22:48 +0000 (10:22 -0700)]
Perldelta final massage for 5.29.8 release

Update perldelta file with recent changes
and perform some extra cleanup.

5 years agoAdd more Travis CI flavors to the matrix
Nicolas R [Thu, 14 Feb 2019 20:57:11 +0000 (13:57 -0700)]
Add more Travis CI flavors to the matrix

This configuration is going to considerably slowing
down smokes but this is a useful alternate when
preparing a release.

We can probably consider commenting these extra config
and only check them for release. Or we could also provide
two travis.yaml:
- .travis.yml.light
- .travis.yml.full

And use a symlink depending which one we want to use.

5 years agoAdd note for BLEAD point release to release_managers_guide.pod
Nicolas R [Wed, 20 Feb 2019 16:32:59 +0000 (09:32 -0700)]
Add note for BLEAD point release to release_managers_guide.pod

Add note concerning the bump of PERL_API_* constants
for blead point releases.

5 years agoTime-HiRes 1.9760 - bump Module::CoreList & co
Nicolas R [Wed, 20 Feb 2019 00:04:33 +0000 (17:04 -0700)]
Time-HiRes 1.9760 - bump Module::CoreList & co

Also bump Porting/Maintainers.pl to synchronize
with the upstream version we are using.

5 years agoDevel::PPPort: Fix D_PPP_FIX_UTF8_ERRSV macro
Pali [Thu, 14 Feb 2019 11:35:23 +0000 (12:35 +0100)]
Devel::PPPort: Fix D_PPP_FIX_UTF8_ERRSV macro

It should use errsv value from passed argument.

5 years agoperldelta for 125ddee8ebdb, 2e51033c15c9
Tony Cook [Wed, 20 Feb 2019 00:53:58 +0000 (11:53 +1100)]
perldelta for 125ddee8ebdb2e51033c15c9

5 years agotest for error set on socket() failure origin/tonyc/socket-error
Tony Cook [Tue, 19 Feb 2019 23:57:19 +0000 (10:57 +1100)]
test for error set on socket() failure

5 years agowin32/win32sck.c: better socket() error handling
Tomasz Konojacki [Tue, 19 Feb 2019 17:16:06 +0000 (18:16 +0100)]
win32/win32sck.c: better socket() error handling

When the protocol passed to socket() is unknown, set errno to
WSAEPROTONOSUPPORT.

[perl #133853]

5 years ago[MERGE] fix PERL_GLOBAL_STRUCT builds
David Mitchell [Tue, 19 Feb 2019 15:41:03 +0000 (15:41 +0000)]
[MERGE] fix PERL_GLOBAL_STRUCT builds

PERL_GLOBAL_STRUCT and DPERL_GLOBAL_STRUCT_PRIVATE builds haven't been
smoked for quite a while and the code has bit-rotted. The commits in
this branch made them build and all test pass again, at least on Linux

5 years agomerge two versions of Perl_my_cxt_init
David Mitchell [Tue, 19 Feb 2019 15:20:16 +0000 (15:20 +0000)]
merge two versions of Perl_my_cxt_init

There are two separate copies of this function, chosen by
the presence of PERL_GLOBAL_STRUCT_PRIVATE. The previous couple of
commits have made them more similar; this commit merges them into a
single function with differing blocks of code protected by
PERL_GLOBAL_STRUCT_PRIVATE

5 years agoPerl_my_cxt_init: remove unnecessary code
David Mitchell [Tue, 19 Feb 2019 14:59:24 +0000 (14:59 +0000)]
Perl_my_cxt_init: remove unnecessary code

In the PERL_GLOBAL_STRUCT_PRIVATE variant of this code, it zeroes out
unused slots of a freshly-realloced PL_my_cxt_list[]. This is not
necessary, as those slots won't be used until a new index is allocated,
as which point the new slot will get written to before anything else.

The non-PERL_GLOBAL_STRUCT_PRIVATE variant of this function doesn't have
this redundant zeroing.

So remove it.

5 years agoharmonise two versions of Perl_my_cxt_init
David Mitchell [Tue, 19 Feb 2019 14:35:31 +0000 (14:35 +0000)]
harmonise two versions of Perl_my_cxt_init

There are two separate copies of this function, chosen by
the presence of PERL_GLOBAL_STRUCT_PRIVATE.

Make the two versions closer to each other, to allow shortly for
merging.

Mainly its renaming the int pointer parameter from 'index' to 'indexp',
and adding a local var 'index', which is assigned from *indexp where
appropriate.

Also harmonise some of the comments between the two functions.

5 years agoperlvars.h: remove #ifdef DEBUGGING
David Mitchell [Tue, 19 Feb 2019 12:29:38 +0000 (12:29 +0000)]
perlvars.h: remove #ifdef DEBUGGING

Under PERL_GLOBAL_STRUCT, all the "global" vars are put in a structure,
which means perlvars.h needs a similar constraint to intrpvar.h:
its size and alignment shouldn't change between debugging and
non-debugging builds. This is because regcomp/exec.c are compiled both
with and without DEBUGGING.

[Fixed by Karl]

5 years agoPERL_GLOBAL_STRUCT: remove static var from sv.c
David Mitchell [Tue, 19 Feb 2019 11:06:38 +0000 (11:06 +0000)]
PERL_GLOBAL_STRUCT: remove static var from sv.c

This var was protected by PERL_GLOBAL_STRUCT_PRIVATE, but
PERL_GLOBAL_STRUCT doesn't allow static vars either.

5 years agoget MakeMaker to play under PERL_GLOBAL_STRUCT
David Mitchell [Tue, 19 Feb 2019 08:53:43 +0000 (08:53 +0000)]
get MakeMaker to play under PERL_GLOBAL_STRUCT

Under PERL_GLOBAL_STRUCT (well, actually I've only tried under
PERL_GLOBAL_STRUCT_PRIVATE), cpan/ExtUtils-MakeMaker/t/03-xsstatic.t
was failing some tests. This was because it was creating a
statically-linked perl binary, but wasn't compiling perlmain.c with
-DPERL_CORE. Usually this doesn't matter, but under PERL_GLOBAL_STRUCT
it needed a definition of aTHX which it was pulling from XSUB.h rather
than perl.h, causing a SEGV.

Until a proper fix makes it way into MakeMaker, explicitly define
PERL_CORE in perlmain.c

5 years agofix thread issue with PERL_GLOBAL_STRUCT
David Mitchell [Mon, 18 Feb 2019 09:29:29 +0000 (09:29 +0000)]
fix thread issue with PERL_GLOBAL_STRUCT

The MY_CXT subsystem allows per-thread pseudo-static data storage.
Part of the implementation for this involves each XS module being
assigned a unique index in its my_cxt_index static var when first
loaded.

Because PERL_GLOBAL_STRUCT bans any static vars, under those builds
there is instead a table which maps the MY_CXT_KEY identifying string to
index.

Unfortunately, this table was allocated per-interpreter rather than
globally, meaning if multiple threads tried to load the same XS module,
crashes could ensue.

This manifested itself in failures in
ext/XS-APItest/t/keyword_plugin_threads.t

The fix is relatively straightforward: allocate PL_my_cxt_keys globally
rather than per-interpreter.

Also record the size of this struct in a new var, PL_my_cxt_keys_size,
rather than doing double duty on PL_my_cxt_size.

5 years agoPerl_my_cxt_init: fix potential race condition
David Mitchell [Mon, 18 Feb 2019 09:19:38 +0000 (09:19 +0000)]
Perl_my_cxt_init: fix potential race condition

(Found by code inspection - I can't reproduce a failure)

the MY_CXT subsystem, which allows per-thread pseudo-static variables,
has a thread race condition.

When a module is first loaded, it is allocated  unique index (from
PL_my_cxt_index++) which is assigned to the module's my_cxt_index static
var.

If two threads both try to load an XS module at the same time, its
possible for one thread to set my_cxtp, then a second thread to overwrite
it with a higher value, causing the first thread to use the wrong index
into its local storage.

5 years agoPL_InBitmap: fix with -DPERL_GLOBAL_STRUCT_PRIVATE
David Mitchell [Fri, 28 Dec 2018 12:50:14 +0000 (12:50 +0000)]
PL_InBitmap: fix with -DPERL_GLOBAL_STRUCT_PRIVATE

Valgrind wasn't happy, as this global var wasn't being initialised to
NULL.

5 years agofoo_cloexec() under PERL_GLOBAL_STRUCT_PRIVATE
David Mitchell [Wed, 26 Dec 2018 12:58:06 +0000 (12:58 +0000)]
foo_cloexec() under PERL_GLOBAL_STRUCT_PRIVATE

Fix the various Perl_PerlSock_dup2_cloexec() type functions so that
t/porting/liberl.a passes under -DPERL_GLOBAL_STRUCT_PRIVATE builds.

In these builds it is forbidden to have any static variables, but each
of these functions (via convoluted macros) has a static var called
'strategy' which records, for each function, whether a run-time probe
has been done to determine the best way of achieving close-exec
functionality, and the result.

Replace them all with 'global' vars: PL_strategy_dup2 etc.

NB these vars aren't thread-safe but it doesn't really matter, as the
worst that can happen is for a redundant probe or two to be done before
a suitable "don't probe any more" value is written to the var and seen
by all the threads.

5 years agoPERL_GLOBAL_STRUCT_PRIVATE: fix some const strings
David Mitchell [Fri, 28 Dec 2018 11:29:27 +0000 (11:29 +0000)]
PERL_GLOBAL_STRUCT_PRIVATE: fix some const strings

change a couple of
    const char * foo[] = { ... }
to
    const char * const foo[] = { ... }

Making the string ptrs const means the whole thing is RO and doesn't
appear in data section, making porting/libperl.t happier when building
under -DPERL_GLOBAL_STRUCT_PRIVATE.

5 years agoregcomp.c: don't include INTERN.h
David Mitchell [Wed, 26 Dec 2018 20:50:16 +0000 (20:50 +0000)]
regcomp.c: don't include INTERN.h

This file only needs including by globals.c; it was being included
in regcomp.c too as the declarations in regcomp.h aren't included by
perl.h and thus don't get pulled into globals.c.  This was a confusing
and hacky workaround.

Instead, this commit causes globals.c to #include regcomp.h directly

After this commit, only globals.c #includes INTERN.h

5 years agoext/SDBM_File/sdbm.c: don't include INTERN.h
David Mitchell [Wed, 26 Dec 2018 20:37:45 +0000 (20:37 +0000)]
ext/SDBM_File/sdbm.c: don't include INTERN.h

This file really only needs including by globals.c - including it in
sdbm.c was probably just a thinko or cut and paste error from decades ago.
Removing it doesn't seem to break anything.

After this commit, only globals.c and regcomp.c include it.

5 years agovutil.c: build under PERL_GLOBAL_STRUCT_PRIVATE
David Mitchell [Wed, 26 Dec 2018 10:41:28 +0000 (10:41 +0000)]
vutil.c: build under PERL_GLOBAL_STRUCT_PRIVATE

The perl build option -DPERL_GLOBAL_STRUCT_PRIVATE had bit-rotted
due to lack of smoking. This commit and the next fix it.
I've separated out the vutil.c change into a separate commit since
this file is actually part of the 'version' CPAN distribution and
normally should be edited upstream first.

5 years agoadd dVAR's for PERL_GLOBAL_STRUCT_PRIVATE builds
David Mitchell [Wed, 26 Dec 2018 10:45:22 +0000 (10:45 +0000)]
add dVAR's for PERL_GLOBAL_STRUCT_PRIVATE builds

The perl build option -DPERL_GLOBAL_STRUCT_PRIVATE had bit-rotted
due to lack of smoking. The main fix is to just add 'dVAR;' to any
functions which have a pTHX arg. It's a NOOP on normal builds.

5 years agore/user_prop_race_thr.t: reduce timeout
David Mitchell [Tue, 19 Feb 2019 09:12:33 +0000 (09:12 +0000)]
re/user_prop_race_thr.t: reduce timeout

This new test script has a test that's supposed to exercise an up-to 10s
wait-and-retry loop when loading properties. It has a 500s timeout
built-in for if that fails. On my system its been intermittently
failing (not sure if due to something I'm doing or a problem with the
test or with regcomp.c) which effectively hangs the test run.

So decrease the timeout to 25 secs.

5 years agoUpdate Time-HiRes Changes for 1.9760
Nicolas R [Mon, 18 Feb 2019 23:42:44 +0000 (16:42 -0700)]
Update Time-HiRes Changes for 1.9760

1.9760 is now released to CPAN to match its status
in blead.

This commit is synchronizing the Changelog, by reintroducing
some history which were lost during previous reverts.

Any new change since cf8375d should now go to the next release 1.9761.
A '{{NEXT}}' entry was added to the Changes for tracking these changes.

Note that a Dual-Life git repository is now available for Time-HiRes.

Upstream-URL: https://github.com/Dual-Life/Time-HiRes

5 years agoUpdate releaser managers
Sawyer X [Mon, 18 Feb 2019 07:36:46 +0000 (09:36 +0200)]
Update releaser managers

5 years agodeprecate: bump $VERSION to 0.04
Aristotle Pagaltzis [Mon, 18 Feb 2019 07:06:30 +0000 (08:06 +0100)]
deprecate: bump $VERSION to 0.04

5 years agodeprecate: expand the documentation
Aristotle Pagaltzis [Sun, 17 Feb 2019 23:14:52 +0000 (00:14 +0100)]
deprecate: expand the documentation

5 years agoprepare next patch
Aristotle Pagaltzis [Sun, 17 Feb 2019 23:14:46 +0000 (00:14 +0100)]
prepare next patch

5 years agodeprecate: fix POD heading level
Aristotle Pagaltzis [Sun, 17 Feb 2019 23:14:38 +0000 (00:14 +0100)]
deprecate: fix POD heading level

5 years agomktables: Omit unnecessary duplicates
Karl Williamson [Sun, 17 Feb 2019 03:02:57 +0000 (20:02 -0700)]
mktables: Omit unnecessary duplicates

These are in a generated structure.

5 years agoperldelta: perldelta for previous commit
Karl Williamson [Sat, 16 Feb 2019 19:14:27 +0000 (12:14 -0700)]
perldelta: perldelta for previous commit

5 years agomalloc.c: Limit malloc size to PTRDIFF_MAX
Karl Williamson [Sat, 16 Feb 2019 18:44:56 +0000 (11:44 -0700)]
malloc.c: Limit malloc size to PTRDIFF_MAX

Without doing this, it is possible that the behavior is undefined when
subtracting two pointers that point to the same object.

See thread beginning at
http://nntp.perl.org/group/perl.perl5.porters/251541

In particular this from Tomasz Konojacki

C11 says:

> When two pointers are subtracted, both shall point to elements of the
> same array object, or one past the last element of the array object;
> the result is the difference of the subscripts of the two array
> elements. The size of the result is implementation-defined, and its
> type (a signed integer type) is ptrdiff_t defined in the <stddef.h>
> header.  If the result is not representable in an object of that type,
> the behavior is undefined.

There are many ways to interpret this passage, but according to (most?)
C compilers developers, it means that no object can be larger than
PTRDIFF_MAX. For example, gcc's optimizer assummes that strlen() will
never return anything larger than PTRDIFF_MAX [1].

There's also a blogpost[2] on this topic, which IMO is a very
interesting read.

If gcc and clang can assume that all objects won't be larger than
PTRDIFF_MAX, so can we. Also, in practice, ssize_t and ptrdiff_t on most
(all?) platforms are defined as exactly the same type.

BTW, the fact that compilers assume that objects can't be larger than
PTRDIFF_MAX has very dangerous implications on 32-bit platforms. Is it
possible to create string longer than PTRDIFF_MAX on 32-bit perls?. It
shouldn't be allowed.

[1] - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78153
[2] - https://trust-in-soft.com/objects-larger-than-ptrdiff_max-bytes/

5 years agoregcomp.c: Don't interate a loop needlessly
Karl Williamson [Sat, 16 Feb 2019 18:29:51 +0000 (11:29 -0700)]
regcomp.c: Don't interate a loop needlessly

While single stepping in gdb, I noticed that this loop kept executing,
when it need not.

5 years agoperldelta for previous commi
Karl Williamson [Sat, 16 Feb 2019 18:29:01 +0000 (11:29 -0700)]
perldelta for previous commi

5 years agoPATCH: [perl #133770] null pointer dereference in S_regclass()
Karl Williamson [Sat, 16 Feb 2019 18:11:59 +0000 (11:11 -0700)]
PATCH: [perl #133770] null pointer dereference in S_regclass()

The failing case can be reduced to

qr/\x{100}[\x{3030}\x{1fb2}/

(It only happens on UTF-8 patterns).

The bottom line is that it was assuming that there was at least one
character that folded to 1fb2 besides itself, even though the function
call said there weren't any such.  The solution is to pay attention to
the function return value.

I incorporated Hugo's++ patch as part of this one.

However, the original test case should never have gotten this far.  The
parser is getting passed garbage, and instead of croaking, it is somehow
interpreting it as valid and calling the regex compiler.  I will file a
ticket about that.