File tree 3 files changed +29
-5
lines changed
3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use warnings;
7
7
8
8
use Scalar::Util qw( reftype refaddr blessed) ;
9
9
10
- our $VERSION = ' 1.55 ' ; # Please update the pod, too.
10
+ our $VERSION = ' 1.56 ' ; # Please update the pod, too.
11
11
my $XS_VERSION = $VERSION ;
12
12
$VERSION = eval $VERSION ;
13
13
@@ -195,7 +195,7 @@ threads::shared - Perl extension for sharing data structures between threads
195
195
196
196
=head1 VERSION
197
197
198
- This document describes threads::shared version 1.55
198
+ This document describes threads::shared version 1.56
199
199
200
200
=head1 SYNOPSIS
201
201
Original file line number Diff line number Diff line change @@ -1104,8 +1104,9 @@ sharedsv_array_mg_CLEAR(pTHX_ SV *sv, MAGIC *mg)
1104
1104
if (!sv ) continue ;
1105
1105
if ( (SvOBJECT (sv ) || (SvROK (sv ) && (sv = SvRV (sv ))))
1106
1106
&& SvREFCNT (sv ) == 1 ) {
1107
- SV * tmp = Perl_sv_newmortal ( caller_perl ) ;
1107
+ SV * tmp ;
1108
1108
PERL_SET_CONTEXT ((aTHX = caller_perl ));
1109
+ tmp = sv_newmortal ();
1109
1110
sv_upgrade (tmp , SVt_RV );
1110
1111
get_RV (tmp , sv );
1111
1112
PERL_SET_CONTEXT ((aTHX = PL_sharedsv_space ));
@@ -1384,8 +1385,9 @@ STORESIZE(SV *obj,IV count)
1384
1385
if ( (SvOBJECT (sv ) || (SvROK (sv ) && (sv = SvRV (sv ))))
1385
1386
&& SvREFCNT (sv ) == 1 )
1386
1387
{
1387
- SV * tmp = Perl_sv_newmortal ( caller_perl ) ;
1388
+ SV * tmp ;
1388
1389
PERL_SET_CONTEXT ((aTHX = caller_perl ));
1390
+ tmp = sv_newmortal ();
1389
1391
sv_upgrade (tmp , SVt_RV );
1390
1392
get_RV (tmp , sv );
1391
1393
PERL_SET_CONTEXT ((aTHX = PL_sharedsv_space ));
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ use ExtUtils::testlib;
17
17
18
18
BEGIN {
19
19
$| = 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 ###
21
21
};
22
22
23
23
use threads;
@@ -445,6 +445,28 @@ ok($destroyed[$ID], 'Scalar object removed from shared scalar');
445
445
::ok($count == $n , " remove array object by undef" );
446
446
}
447
447
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
+ }
448
470
449
471
450
472
# EOF
You can’t perform that action at this time.
0 commit comments