diff --git a/GObject.xs b/GObject.xs index 53ee0cc..20b5262 100644 --- a/GObject.xs +++ b/GObject.xs @@ -788,6 +788,13 @@ gobject_destroy_wrapper (SV *obj) * otherwise end up with undead HVs hanging on to garbage. Prior to * 5.16, this did not matter, but recent versions of perl will find * these HVs and call DESTROY on them. */ +#if PERL_API_VERSION <= 14 + /* For older versions though, the HVs or the interpreter are already + * dead, so either trying to access the HV or perl internals will + * cause a segmentation fault. */ + if (PL_in_clean_objs || IS_UNDEAD (obj)) + return; +#endif #ifdef NOISY warn ("gobject_destroy_wrapper (%p)[%d]\n", obj,