Should OCaml's Marshal module include a version header for forward‑compatible backup restoration?
0 reputation · 20 Aug 2020, 14:04 UTC
Goal: guarantee that a marshaled value created with one OCaml compiler version can be safely deserialized by a later version without silent corruption or Marshal.Error.
Constraint: the current Marshal format contains no version field, so differences in the binary layout between releases can cause deserialization to fail or reconstruct an incorrect value; additionally, marshalling is not portable across 32‑/64‑bit architectures and poses code‑execution risks with untrusted data.
Uncertainty: the OCaml community has not agreed on whether to extend Marshal with a version header to provide forward‑compatible guarantees, and if so, what format and placement would minimize overhead while preserving existing behavior.
What minimal version identifier could be added without breaking existing marshaled blobs? How would the header affect round‑trip size and deserialization speed? What migration strategy would allow older code to continue reading blobs produced before the change?