From: Yitzchak Scott-Thoennes Date: Fri, 7 Mar 2003 13:12:49 +0000 (-0800) Subject: Re: odd (or not so odd?) segmentation fault in 5.8.0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b77f7d40943072c6b8a82e9e0fbdcc2d346120ee;p=p5sagit%2Fp5-mst-13.2.git Re: odd (or not so odd?) segmentation fault in 5.8.0 Message-ID: p4raw-id: //depot/perl@18889 --- diff --git a/mg.c b/mg.c index 941338b..98e4c09 100644 --- a/mg.c +++ b/mg.c @@ -133,6 +133,12 @@ Perl_mg_get(pTHX_ SV *sv) if (!(mg->mg_flags & MGf_GSKIP) && vtbl && vtbl->svt_get) { CALL_FPTR(vtbl->svt_get)(aTHX_ sv, mg); + + /* guard against sv having been freed */ + if (SvTYPE(sv) == SVTYPEMASK) { + Perl_croak(aTHX_ "Tied variable freed while still in use"); + } + /* Don't restore the flags for this entry if it was deleted. */ if (mg->mg_flags & MGf_GSKIP) (SSPTR(mgs_ix, MGS *))->mgs_flags = 0; diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 3881288..cb314e9 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3672,6 +3672,12 @@ target of the change to (F) The entry point function of threads->create() failed for some reason. +=item Tied variable freed while still in use + +(F) An access method for a tied variable (e.g. FETCH) did something to +free the variable. Since continuing the current operation is likely +to result in a coredump, Perl is bailing out instead. + =item times not implemented (F) Your version of the C library apparently doesn't do times(). I diff --git a/t/op/tie.t b/t/op/tie.t index 6e73cee..49c189e 100755 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -286,3 +286,12 @@ EXPECT 7 8 0 +######## +# +# FETCH freeing tie'd SV +sub TIESCALAR { bless [] } +sub FETCH { *a = \1; 1 } +tie $a, 'main'; +print $a; +EXPECT +Tied variable freed while still in use at - line 6.