Fix crashes due to Problem serialization.

Authored by mwolff on Feb 11 2014, 11:09 PM.

Description

Fix crashes due to Problem serialization.

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

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.

  1. 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

Details

Committed
mwolffFeb 11 2014, 11:19 PM
Parents
R32:254b7f1c7871: Add unit test for ProblemSerialization, it will crash as-is.
Branches
Unknown
Tags
Unknown