This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #37919] Blessed scalar refs with threads::shared
[perl5.git] / ext / threads / shared / shared.xs
index aa1dcf2..c902683 100644 (file)
@@ -378,6 +378,13 @@ Perl_sharedsv_associate(pTHX_ SV **psv, SV *ssv, shared_sv *data)
                                &sharedsv_scalar_vtbl, (char *)data, 0);
                mg->mg_flags |= (MGf_COPY|MGf_DUP);
                SvREFCNT_inc(ssv);
+               if(SvOBJECT(ssv)) {
+                 STRLEN len;
+                 char* stash_ptr = SvPV((SV*) SvSTASH(ssv), len);
+                 HV* stash = gv_stashpvn(stash_ptr, len, TRUE);
+                 SvOBJECT_on(sv);
+                 SvSTASH_set(sv, (HV*)SvREFCNT_inc(stash));
+               }
            }
            break;
        }