From: Dave Mitchell Date: Thu, 6 Nov 2003 22:11:23 +0000 (+0000) Subject: bugid #24407: numeric key for shared hash got stringified using X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=680c9d89d8bf44626bfab3d15bb673204f3e6d39;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs index 12d8078..dd7724e 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 aef965e..ac35489 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");