Skip to content
Commit 83365b0c authored by Milian Wolff's avatar Milian Wolff
Browse files

Fix crashes due to Problem serialization.

This is a major refactoring of the initial problem serialization
code as introduced by 0c2eb5c7.

We now add "proper" support for serializing data items which inherit
QSharedData in the top context file, i.e. TopDUContextDynamicData.

Shared data items are special, as in order to keep the expected
invariants we deviate from other items behavior when serializing:

1) When an item is serialized, we do not change the d_ptr of the
Item, i.e. the data will still point to the dynamic data and never
to the constant serialized data.

2) When deserializing, similar to above, we make the item dynamic
instantly such that the Item is not pointing to the constant data.

This is required in order to prevent double deletions or crashes
due to use-after-free when a shared data pointer outlives the
"parent" TopDUContext. When that one is deleted, or saved to disk,
we previously deleted items (as we assumed to have ownership), and
unmapped the data - thus shared data pointers must never point to
the mmapped data regions.

While complicated and big, I think this patch is cleaner than my
initial implementation. And since the previously added test now
passes, I'm confident this is an improvement. Memory is also still
cleaned up as before.

BUG: 330599
parent 254b7f1c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment