In newXS, clear glob slot before lowering refcount.
Otherwise, when newXS redefines a sub, the previous sub’s DESTROY can
see the same sub still in the typeglob, but without a reference count,
so *typeglob = sub {} frees the sub currently in $_[0].
$ perl5.18.1 -le '
sub re::regmust{}
bless \&re::regmust;
DESTROY {
print "before: $_[0]"; *re::regmust=sub{}; print "after: $_[0]"
}
require re;
'
before: main=CODE(0x7ff7eb02d6d8)
before: main=CODE(0x7ff7eb02d6d8)
after: main=CODE(0x7ff7eb02d6d8)
after: UNKNOWN(0x7ff7eb02d6d8)