On Sat, May 21, 2005 at 04:25:10PM -0000, Nicholas Clark wrote:
> There is a bug in duping - GvHV() can end up pointing at garbage.



I can reproduce it with:

    our $foo : unique = 'abc';
    use threads;
    threads->create(sub { 1} )->join();

It seems to be down to the code in S_gv_share(), which at clone time
basically fills all unused slots (eg gv_hv) in the :unique GV with
&PL_sv_no from the *parent* thread:

    /* attempt to make everything in the typeglob readonly */

    STATIC SV *
    S_gv_share(pTHX_ SV *sstr, CLONE_PARAMS *param)
    {
        GV *gv = (GV*)sstr;
        SV *sv = &param->proto_perl->Isv_no; /* just need SvREADONLY-ness */

        ...

        /*
         * write attempts will die with
         * "Modification of a read-only value attempted"
         */
        if (!GvSV(gv)) {
            GvSV(gv) = sv;
        }

-- 
The Enterprise's efficient long-range scanners detect a temporal vortex
distortion in good time, allowing it to be safely avoided via a minor
course correction.
    -- Things That Never Happen in "Star Trek" #21

Reply via email to