}
STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
- SV *wiz = (SV *) mg->mg_ptr;
const MGWIZ *w;
unsigned int flags;
int ret = 0;
- /* This may happen in global destruction */
- if (SvTYPE(wiz) == SVTYPEMASK)
+ /* Don't even bother if we are in global destruction - the wizard is prisoner
+ * of circular references and we are way beyond user realm */
+ if (PL_dirty)
return 0;
w = SV2MGWIZ(mg->mg_ptr);