Open frejanordsiek opened 3 years ago
After making an initial failed attempt, it looks like this is going to require a massive re-architecturing of the Marshaller API. Marshalling is going to have to some degree be two pass instead of single pass.
I've been thinking about this more and I think it is actually a bad idea to have write support for circular objects because earlier versions of this software would crash on them and it is highly likely that similar packages on other ecosystems and Matlab would crash on them.
However, read support is a good thing and the write system does still need to detect circular objects in order to reject them instead of crashing.
At present, circular objects (e.g. a list with an element that is itself) are not properly detected and the package will keep recursing deeper and deeper in the circular structure until either the recursion limit is reached, the stack is blown, until it runs out of RAM, or it runs out of disk space (if writing). The lack of handling is a bug since it is input that the package can't handle in any way (even rejection).
Circular object detection and handling would prevent this problem, though the prevention does cost some CPU time and RAM to keep track of the already written/read objects.