bugid #24407: numeric key for shared hash got stringified using
Dave Mitchell [Thu, 6 Nov 2003 22:11:23 +0000 (22:11 +0000)]
wrong interpreter, and thus got malloced into the wrong thread
memory pool

p4raw-id: //depot/perl@21676

ext/threads/shared/shared.xs
ext/threads/shared/t/hv_simple.t

index 12d8078..dd7724e 100644 (file)
@@ -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;
index aef965e..ac35489 100644 (file)
@@ -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");