Description
The code in src/dump.c
and src/staticdata.c
does not allow customization of how instances of specific types are serialized.
That is a problem for structs that store Ptr
to external data: if one uses instances of these on the global level in a package module, then the (de)serialized data contains garbage pointers. Funcrashes ensue. See e.g. Nemocas/Nemo.jl#810 for a real life instance of this.
Indeed, the Julia stdlib is affected by this: BigInt
wraps GMP... it only "works" because src/dump.c
resp. src/staticdata.c
contain custom code to deal with (de)serializing BigInt
.
It would be nice if packages could also hook into this serialization code. I realize this may be difficult to achieve. So as an intermediate stop-gap solution, it would be nice if at the least one could mark types such that any attempts to serialize an instance of them leads to an precompilation error. That way, at least one can prevent accidental misuses. I would hope this is much simpler to implement.
ADDED: The same API presumably could also be used to allow (de)serializing instances of "foreign types", created via jl_new_foreign_type