Skip to content

Record the first-registered serializer's tracking flag on save#350

Merged
gennaroprota merged 1 commit into
developfrom
fix/consistent-tracking-flag
Jul 21, 2026
Merged

Record the first-registered serializer's tracking flag on save#350
gennaroprota merged 1 commit into
developfrom
fix/consistent-tracking-flag

Conversation

@gennaroprota

Copy link
Copy Markdown
Collaborator

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.

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.
@gennaroprota
gennaroprota added this pull request to the merge queue Jul 21, 2026
Merged via the queue into develop with commit 2780686 Jul 21, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant