Closed brodieG closed 4 years ago
Problem seems to be that detach
calls methods:::cacheMetaData
in detach mode, which then calls:
.uncacheClass(cl, cldef)
.removeSuperclassBackRefs(cl, cldef, searchWhere)
But neither of these force re-caching of the subclasses. .removeSuperclassBackRefs
removes references in the superclass this contains, whereas we need the opposite, to remove the references from the classes that contain it. Maybe something like:
.uncacheClass(cl, cldef)
.removeSuperclassBackRefs(cl, cldef, searchWhere)
.recacheSubclasses(def@className, def, doSubclasses, env)
Would do the trick? Actually nope, it won't. That just adds references, it does not remove them.
So figured out the problem, as described here: https://stat.ethz.ch/pipermail/r-devel/2019-January/077206.html
Next step is probably to add calls to removeClass
for every class union in every namespace that is successfully unloaded. While the call to removeClass
itself will fail due to the rm
at the end on the locked namespace, most of the prior steps that do what we need should happen.
Unfortunately I didn't resolve this back then, but I believe this is fixed based on R3.6.0 NEWS:
\item Class unions are unloaded when their namespace is
unloaded (\PR{17531}, adapted from a patch by Brodie Gaslam).
Possibly related to #110.
Trying to come up with a more reproducible result, but in the meantime, this is a unitizer that was created with among other things,
diffobj
on the search path. As best I can tall any slot that is of a class that overlaps with class unions from packages that were unloaded cause validations on failure.