summaryrefslogtreecommitdiff
path: root/dist/threads
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-09-04 09:54:58 +0100
committerDavid Mitchell <davem@iabyn.com>2017-09-04 11:09:06 +0100
commit97fcda75b598695644a4ad496e090941f5b7dcbc (patch)
treec5519547d67620ee702238279a838a29b4638cb4 /dist/threads
parentf6107ca24b4cf22dcf7fd69d65612ad718c48fca (diff)
downloadperl-97fcda75b598695644a4ad496e090941f5b7dcbc.tar.gz
threads.xs: don't Copy() null pointer
If a thread is created with no parameters, e.g. use threads; threads->new(sub {})->join; Then it tries to Copy() zero parameters to AvARRAY(params), which is null. Since v5.27.3-31-gf14cf36, this triggers an assert failure, so threaded builds have been badly broken.
Diffstat (limited to 'dist/threads')
-rw-r--r--dist/threads/lib/threads.pm2
-rw-r--r--dist/threads/threads.xs13
2 files changed, 9 insertions, 6 deletions
diff --git a/dist/threads/lib/threads.pm b/dist/threads/lib/threads.pm
index b20087ba84..c30bfdbe0f 100644
--- a/dist/threads/lib/threads.pm
+++ b/dist/threads/lib/threads.pm
@@ -5,7 +5,7 @@ use 5.008;
use strict;
use warnings;
-our $VERSION = '2.17';
+our $VERSION = '2.18';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
diff --git a/dist/threads/threads.xs b/dist/threads/threads.xs
index b70c15fb37..49a700f2cd 100644
--- a/dist/threads/threads.xs
+++ b/dist/threads/threads.xs
@@ -870,15 +870,18 @@ S_ithread_create(
reallocated (and hence move) as a side effect of calls to
perl_clone() and sv_dup_inc(). Hence copy the parameters
somewhere under our control first, before duplicating. */
+ if (num_params) {
#if (PERL_VERSION > 8)
- Copy(parent_perl->Istack_base + params_start, array, num_params, SV *);
+ Copy(parent_perl->Istack_base + params_start, array, num_params, SV *);
#else
- Copy(parent_perl->Tstack_base + params_start, array, num_params, SV *);
+ Copy(parent_perl->Tstack_base + params_start, array, num_params, SV *);
#endif
- while (num_params--) {
- *array = sv_dup_inc(*array, clone_param);
- ++array;
+ while (num_params--) {
+ *array = sv_dup_inc(*array, clone_param);
+ ++array;
+ }
}
+
#if (PERL_VERSION > 13) || (PERL_VERSION == 13 && PERL_SUBVERSION > 1)
Perl_clone_params_del(clone_param);
#endif