Revision 83365b0...

Go back to digest for 16th February 2014

Bug Fixes in Development Tools

Milian Wolff committed changes in [kdevplatform] /duchain:

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.

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.

File Changes

Modified 6 files
  • /duchain
  •   language/problem.cpp
  •   language/problem.h
  •   language/topducontext.cpp
  •   language/topducontext.h
  •   language/topducontextdynamicdata.cpp
  •   language/topducontextdynamicdata.h
6 files changed in total