Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 4f18840

Browse files
committed
threads-shared-1.57
but keep our taint appveyor fix for t/waithires.t
1 parent e6d692f commit 4f18840

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

Porting/Maintainers.pl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ package Maintainers;
14401440
},
14411441

14421442
'threads::shared' => {
1443-
'DISTRIBUTION' => 'JDHEDDEN/threads-shared-1.52.tar.gz',
1443+
'DISTRIBUTION' => 'JDHEDDEN/threads-shared-1.57.tar.gz',
14441444
'FILES' => q[dist/threads-shared],
14451445
'EXCLUDED' => [
14461446
qw( examples/class.pl
@@ -1449,6 +1449,7 @@ package Maintainers;
14491449
t/test.pl
14501450
),
14511451
],
1452+
'CUSTOMIZED' => [ qw( t/waithires.t ) ],
14521453
},
14531454

14541455
'Tie::File' => {

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16187,6 +16187,7 @@ our %delta = (
1618716187
'Test::Harness' => '3.39',
1618816188
'Thread::Queue' => '3.12',
1618916189
'threads' => '2.18_01',
16190+
'threads::shared' => '1.57',
1619016191
'Time::HiRes' => '1.9751',
1619116192
'Time::Piece' => '1.3203',
1619216193
'Unicode::Collate' => '1.25_01',

dist/threads-shared/lib/threads/shared.pm

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use warnings;
77

88
use Scalar::Util qw(reftype refaddr blessed);
99

10-
our $VERSION = '1.52'; # Please update the pod, too.
10+
our $VERSION = '1.57'; # Please update the pod, too.
1111
my $XS_VERSION = $VERSION;
1212
$VERSION = eval $VERSION;
1313

@@ -195,7 +195,7 @@ threads::shared - Perl extension for sharing data structures between threads
195195
196196
=head1 VERSION
197197
198-
This document describes threads::shared version 1.52
198+
This document describes threads::shared version 1.57
199199
200200
=head1 SYNOPSIS
201201
@@ -570,16 +570,18 @@ not propagate the blessing to the shared reference:
570570
Therefore, you should bless objects before sharing them.
571571
572572
It is often not wise to share an object unless the class itself has been
573-
written to support sharing. For example, an object's destructor may get
574-
called multiple times, once for each thread's scope exit. Another danger is
575-
that the contents of hash-based objects will be lost due to the above
576-
mentioned limitation. See F<examples/class.pl> (in the CPAN distribution of
577-
this module) for how to create a class that supports object sharing.
573+
written to support sharing. For example, a shared object's destructor may
574+
get called multiple times, once for each thread's scope exit, or may not
575+
get called at all if it is embedded inside another shared object. Another
576+
issue is that the contents of hash-based objects will be lost due to the
577+
above mentioned limitation. See F<examples/class.pl> (in the CPAN
578+
distribution of this module) for how to create a class that supports object
579+
sharing.
578580
579581
Destructors may not be called on objects if those objects still exist at
580582
global destruction time. If the destructors must be called, make sure
581583
there are no circular references and that nothing is referencing the
582-
objects, before the program ends.
584+
objects before the program ends.
583585
584586
Does not support C<splice> on arrays. Does not support explicitly changing
585587
array lengths via $#array -- use C<push> and C<pop> instead.

dist/threads-shared/shared.xs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,18 @@ Perl_sharedsv_cond_timedwait(perl_cond *cond, perl_mutex *mut, double abs)
656656
abs -= (NV)ts.tv_sec;
657657
ts.tv_nsec = (long)(abs * 1000000000.0);
658658

659+
#if defined(CLANG_DIAG_IGNORE)
660+
CLANG_DIAG_IGNORE(-Wthread-safety);
661+
/* warning: calling function 'pthread_cond_timedwait' requires holding mutex 'mut' exclusively [-Wthread-safety-analysis] */
662+
#endif
663+
659664
switch (pthread_cond_timedwait(cond, mut, &ts)) {
665+
666+
/* perl.h defines CLANG_DIAG_* but only in 5.24+ */
667+
#if defined(CLANG_DIAG_RESTORE)
668+
CLANG_DIAG_RESTORE;
669+
#endif
670+
660671
case 0: got_it = 1; break;
661672
case ETIMEDOUT: break;
662673
#ifdef OEMVS
@@ -1094,8 +1105,9 @@ sharedsv_array_mg_CLEAR(pTHX_ SV *sv, MAGIC *mg)
10941105
if (!sv) continue;
10951106
if ( (SvOBJECT(sv) || (SvROK(sv) && (sv = SvRV(sv))))
10961107
&& SvREFCNT(sv) == 1 ) {
1097-
SV *tmp = Perl_sv_newmortal(caller_perl);
1108+
SV *tmp;
10981109
PERL_SET_CONTEXT((aTHX = caller_perl));
1110+
tmp = sv_newmortal();
10991111
sv_upgrade(tmp, SVt_RV);
11001112
get_RV(tmp, sv);
11011113
PERL_SET_CONTEXT((aTHX = PL_sharedsv_space));
@@ -1374,8 +1386,9 @@ STORESIZE(SV *obj,IV count)
13741386
if ( (SvOBJECT(sv) || (SvROK(sv) && (sv = SvRV(sv))))
13751387
&& SvREFCNT(sv) == 1 )
13761388
{
1377-
SV *tmp = Perl_sv_newmortal(caller_perl);
1389+
SV *tmp;
13781390
PERL_SET_CONTEXT((aTHX = caller_perl));
1391+
tmp = sv_newmortal();
13791392
sv_upgrade(tmp, SVt_RV);
13801393
get_RV(tmp, sv);
13811394
PERL_SET_CONTEXT((aTHX = PL_sharedsv_space));

dist/threads-shared/t/object2.t

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ExtUtils::testlib;
1717

1818
BEGIN {
1919
$| = 1;
20-
print("1..131\n"); ### Number of tests that will be run ###
20+
print("1..133\n"); ### Number of tests that will be run ###
2121
};
2222

2323
use threads;
@@ -445,6 +445,28 @@ ok($destroyed[$ID], 'Scalar object removed from shared scalar');
445445
::ok($count == $n, "remove array object by undef");
446446
}
447447

448+
# RT #131124
449+
# Emptying a shared array creates new temp SVs. If there are no spare
450+
# SVs, a new arena is allocated. shared.xs was mallocing a new arena
451+
# with the wrong perl context set, meaning that when the arena was later
452+
# freed, it would "panic: realloc from wrong pool"
453+
#
454+
455+
{
456+
threads->new(sub {
457+
my @a :shared;
458+
push @a, bless &threads::shared::share({}) for 1..1000;
459+
undef @a; # this creates lots of temp SVs
460+
})->join;
461+
ok(1, "#131124 undef array doesnt panic");
462+
463+
threads->new(sub {
464+
my @a :shared;
465+
push @a, bless &threads::shared::share({}) for 1..1000;
466+
@a = (); # this creates lots of temp SVs
467+
})->join;
468+
ok(1, "#131124 clear array doesnt panic");
469+
}
448470

449471

450472
# EOF

pod/perlcdelta.pod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ Updated from 3.01, many critical fixes.
243243

244244
=item L<threads> 2.18_01
245245

246+
=item L<threads::shared> 1.57
247+
246248
=item L<Time::HiRes> 1.9751
247249

248250
=item L<Time::Piece> 1.3203

t/porting/customized.dat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ lib dist/lib/lib_pm.PL 6f1951dc926375aa93b93515aa5f3c1ca1396b05
101101
threads dist/threads/lib/threads.pm 532c5f595f81666fa7ff534a919cbf679dae9b8a
102102
threads dist/threads/t/locale.t 9a2a5b43a39867590eb288d4a1759abac2052aa8
103103
threads dist/threads/threads.xs 030620f4374ad62176e3c5d4d24b2dbd90a12b69
104+
threads::shared dist/threads-shared/t/waithires.t dc867159fd2fa8c09326cd7627f5a0635ca5e3b5
104105
version cpan/version/lib/version.pm 46e7b7eed74b5080b23f852acd84e6ca5aab6d74
105106
version cpan/version/lib/version/regex.pm a2e6098571d8085340d4378ec21ad54bbcce1ceb
106107
version vutil.c 9112461d000e5d9ad60de8105fb803a639cbe020

0 commit comments

Comments
 (0)