summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2014-10-13 12:45:14 +0100
committerDavid Mitchell <davem@iabyn.com>2014-10-14 12:33:06 +0100
commit399547d72ff67024bd23426fc6e6aa2593d47a9e (patch)
tree5fb87e64effa241f683d41a1758c04832e90a91f
parent0561e60b8176e7cda2f409814c660336f3e25fb6 (diff)
downloadperl-399547d72ff67024bd23426fc6e6aa2593d47a9e.tar.gz
threads::shared "$#shared = N" off-by-one error
RT #122950 my @a : shared; $#a = 3; # actually set it to 4 There was a simple off-by-one error in the XS code that handled the STORESIZE tie method (confusing the array size and fill, which differ by 1). Amazingly, there was no test for it, and no-one had noticed up until now. Note that this commit causes three tests in object2.t to fail: this is because fixing the $#shared bug exposed another bug that was being masked by this one. They will be fixed in the next commit
-rw-r--r--dist/threads-shared/lib/threads/shared.pm4
-rw-r--r--dist/threads-shared/shared.xs2
-rw-r--r--dist/threads-shared/t/av_simple.t12
3 files changed, 14 insertions, 4 deletions
diff --git a/dist/threads-shared/lib/threads/shared.pm b/dist/threads-shared/lib/threads/shared.pm
index bad2c41253..304891cf31 100644
--- a/dist/threads-shared/lib/threads/shared.pm
+++ b/dist/threads-shared/lib/threads/shared.pm
@@ -7,7 +7,7 @@ use warnings;
use Scalar::Util qw(reftype refaddr blessed);
-our $VERSION = '1.46'; # Please update the pod, too.
+our $VERSION = '1.47'; # Please update the pod, too.
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
@@ -195,7 +195,7 @@ threads::shared - Perl extension for sharing data structures between threads
=head1 VERSION
-This document describes threads::shared version 1.46
+This document describes threads::shared version 1.47
=head1 SYNOPSIS
diff --git a/dist/threads-shared/shared.xs b/dist/threads-shared/shared.xs
index f59a82a6de..8e41139b02 100644
--- a/dist/threads-shared/shared.xs
+++ b/dist/threads-shared/shared.xs
@@ -1373,7 +1373,7 @@ STORESIZE(SV *obj,IV count)
dTHXc;
SV *sobj = SHAREDSV_FROM_OBJ(obj);
SHARED_EDIT;
- av_fill((AV*) sobj, count);
+ av_fill((AV*) sobj, count - 1);
SHARED_RELEASE;
diff --git a/dist/threads-shared/t/av_simple.t b/dist/threads-shared/t/av_simple.t
index 7fab9b2b76..305c6d52b9 100644
--- a/dist/threads-shared/t/av_simple.t
+++ b/dist/threads-shared/t/av_simple.t
@@ -27,7 +27,7 @@ sub ok {
BEGIN {
$| = 1;
- print("1..44\n"); ### Number of tests that will be run ###
+ print("1..47\n"); ### Number of tests that will be run ###
};
use threads;
@@ -130,6 +130,16 @@ ok(37, !defined delete($foo[0]), "Check that delete works from a thread");
ok(44, is_shared(@foo), "Check for sharing");
+# RT #122950
+
+@foo = ('a'..'z');
+$#foo = 2;
+
+ok(45, $#foo == 2, "\$#foo assignment: \$#");
+ok(46, @foo == 3, "\$#foo assignment: scalar");
+ok(47, "@foo" eq "a b c", "\$#foo assignment: array interpolation");
+
+
exit(0);
# EOF