Skip to content
Prev 55611 / 63421 Next

SIGSEGV in R_RunWeakRefFinalizer, object allocated with Rcpp

Hi I?aki,

I think that "still reachable" memory is potentially a problem only if 
you cared about (frequent) package unloading, and if package unloading 
did not have correctness problems in the first place. I would only worry 
about "memory leaks" reported by valgrind.

That your example (unloading a library while there is still an object 
with a finalizer implemented in that library) segfaults on one system 
but not another is not too surprising. Depending on the OS, the dynamic 
linker, the current state of the system, etc - when the GC tries to run 
the finalizer, it may point to inaccessible memory (segfault), but also 
still to the code of the unloaded finalizer (possibly no segfault) or 
something else. There is no way to distinguish between all these cases 
before running the finalizer - neither the OS nor R can do it - we could 
only in principle, with a lot of other problems and platform-dependent 
hacks, detect when the memory is inaccessible, but that may not be worth it.

Best
Tomas
On 08/10/2018 12:46 AM, I?aki ?car wrote: