Record the first-registered serializer's tracking flag on save#350
Merged
Conversation
Since 1.85, a Derived object serialized through a Base pointer across module boundaries loses its data on load: the base subobject reads back empty. PR #287 changed save to decide whether to emit an object id from `co.m_bos_ptr` (the first serializer instance registered for a type), but left the tracking flag written into the class preamble taken from `bos`, the instance the current call happens to use. Those can differ. With `track_selectively`, two module-local serializer singletons for one type report different `tracking()`: the one whose pointer serializer has been registered has `serialized_as_pointer()` true, the other false. The writer then records one flag but lays the object out per the other, so the reader desyncs and the subobject is misread. Record `co.m_bos_ptr`'s flag, the same instance the id decision uses, so save is self-consistent again, as it was before PR #287 when both sides read `bos`. The output is byte-identical whenever `co.m_bos_ptr == &bos` (every single-module archive); only the already-broken cross-module case changes. Fixes issue #329.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 1.85, a Derived object serialized through a Base pointer across module boundaries loses its data on load: the base subobject reads back empty. PR #287 changed save to decide whether to emit an object id from
co.m_bos_ptr(the first serializer instance registered for a type), but left the tracking flag written into the class preamble taken frombos, the instance the current call happens to use.Those can differ. With
track_selectively, two module-local serializer singletons for one type report differenttracking(): the one whose pointer serializer has been registered hasserialized_as_pointer()true, the other false. The writer then records one flag but lays the object out per the other, so the reader desyncs and the subobject is misread.Record
co.m_bos_ptr's flag, the same instance the id decision uses, so save is self-consistent again, as it was before PR #287 when both sides readbos. The output is byte-identical wheneverco.m_bos_ptr == &bos(every single-module archive); only the already-broken cross-module case changes.Fixes issue #329.