summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorDave Mitchell <davem@fdisolutions.com>2003-11-06 22:11:23 +0000
committerDave Mitchell <davem@fdisolutions.com>2003-11-06 22:11:23 +0000
commit680c9d89d8bf44626bfab3d15bb673204f3e6d39 (patch)
treeace2baa04f140a5380c92d8132ed14ff200e1958 /ext
parentdd0810f9b6071d97b916f3789cf75dfc6e540687 (diff)
downloadperl-680c9d89d8bf44626bfab3d15bb673204f3e6d39.tar.gz
bugid #24407: numeric key for shared hash got stringified using
wrong interpreter, and thus got malloced into the wrong thread memory pool p4raw-id: //depot/perl@21676
Diffstat (limited to 'ext')
-rw-r--r--ext/threads/shared/shared.xs3
-rw-r--r--ext/threads/shared/t/hv_simple.t9
2 files changed, 9 insertions, 3 deletions
diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs
index 12d80789a0..dd7724e805 100644
--- a/ext/threads/shared/shared.xs
+++ b/ext/threads/shared/shared.xs
@@ -911,13 +911,14 @@ EXISTS(shared_sv *shared, SV *index)
CODE:
dTHXc;
bool exists;
- SHARED_EDIT;
if (SvTYPE(SHAREDSvPTR(shared)) == SVt_PVAV) {
+ SHARED_EDIT;
exists = av_exists((AV*) SHAREDSvPTR(shared), SvIV(index));
}
else {
STRLEN len;
char *key = SvPV(index,len);
+ SHARED_EDIT;
exists = hv_exists((HV*) SHAREDSvPTR(shared), key, len);
}
SHARED_RELEASE;
diff --git a/ext/threads/shared/t/hv_simple.t b/ext/threads/shared/t/hv_simple.t
index aef965efb7..ac35489870 100644
--- a/ext/threads/shared/t/hv_simple.t
+++ b/ext/threads/shared/t/hv_simple.t
@@ -32,7 +32,7 @@ sub skip {
use ExtUtils::testlib;
use strict;
-BEGIN { print "1..14\n" };
+BEGIN { print "1..15\n" };
use threads;
use threads::shared;
ok(1,1,"loaded");
@@ -63,5 +63,10 @@ ok(10, $seen{1} == 1, "Keys..");
ok(11, $seen{2} == 1, "Keys..");
ok(12, $seen{3} == 1, "Keys..");
ok(13, $seen{"foo"} == 1, "Keys..");
+
+# bugid #24407: the stringification of the numeric 1 got allocated to the
+# wrong thread memory pool, which crashes on Windows.
+ok(14, exists $hash{1}, "Check numeric key");
+
threads->create(sub { %hash = () })->join();
-ok(14, keys %hash == 0, "Check clear");
+ok(15, keys %hash == 0, "Check clear");