-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core dumping R if using a serialized 'big.matrix' object #100
Comments
I think this behaviour is fairly known, and this is why descriptors are used instead in parallel settings. A cleaner way would be to use active bindings of reference classes as proposed in https://github.com/phaverty/bigmemoryExtras by @phaverty, which I've borrowed in bigstatsr. |
I realized my request for a bug fix was not clear. I'm not asking to make it possible to export bigmemory objects. The ask is to detect the problem and give an informative error message rather than core dumping. I've updated my top comment accordingly. |
Apparently, {magick} has a way to prevent from this: library(magick)
tiger <- image_read_svg('http://jeroen.github.io/images/tiger.svg', width = 400)
saveRDS(tiger, tmp <- tempfile(fileext = ".rds"))
readRDS(tmp)
But I'm not sure how they manage to do this. |
Maybe @jeroen can give a clue. |
You just need to check that your XPtr is not NULL, before using it, everywhere where you use:
|
I've just tried checking for |
That gives you the address of the SEXP object itself. To get the externalpointer, I think you need You can also use |
That is very useful information, thanks! |
I've tried using From what I see from {magick}, you do As {bigmemory} is not using an RC object (but S4), I'm not sure it can use active bindings. |
All that the assert_image function in magick does is call magick_image_dead which checks if the pointer is NULL. |
Hi, I discovered that bigmemory core dumps (=crashes/terminates) parallel workers if attempting to use 'big.memory' objects. This appears to be because there is an assumption that the object is always used in the same R process that it was created in, which does not work because of the external pointer. Here is a minimal reproducible example:
In one R session, do:
In another R session, do:
Suggestion
Instead of core dumping, detect the problem and give an informative error message:
I don't know the internals, but I assume the problem is that the external pointer:
is used without making sure it is still valid.
PS. I consider this a quite serious bug since it can core dump R and parallel workers in R and it's hard to protect against it. People who run parallel code might not even know that bigmemory is used as part of some other package they rely on. This is the first package that I know of that use external pointers that also core dumps R, cf. https://cran.r-project.org/web/packages/future/vignettes/future-4-non-exportable-objects.html. It looks like those other packages can detect the problem and prevent core dumping, so, hopefully, it is not to hard to protect against this.
EDIT 2020-08-15 @ 18:11 UTC: Clarified that the bug fix should be to give an informative error message instead of core dumping.
The text was updated successfully, but these errors were encountered: