Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Fix GeoJSONVTData ownership and life cycle #16106

Merged
merged 1 commit into from
Jan 9, 2020

Conversation

pozdnyakov
Copy link
Contributor

Before this change, the GeoJSONVTData instance was retained at the scheduled
lambda, which run on the worker thread represented by the GeoJSONVTData::scheduler
class member:

        std::weak_ptr<GeoJSONVTData> weak = shared_from_this();
        scheduler->scheduleAndReplyValue(
            [id, weak, this]() -> TileFeatures {
                if (auto self = weak.lock()) {
                    return impl.getTile(id.z, id.x, id.y).features;
                }
                return {};
            },
            fn);

It caused program termination in case self turned to be the last reference to this,
as the std::thread destructor was called from the thread it represented.

Now, only the GeoJSONVTData::impl class member is retained.

Fixes: #16101

Before this change, the `GeoJSONVTData` instance was retained at the scheduled
lambda, which run on the worker thread represented by the `GeoJSONVTData::scheduler`
class member:

```
        std::weak_ptr<GeoJSONVTData> weak = shared_from_this();
        scheduler->scheduleAndReplyValue(
            [id, weak, this]() -> TileFeatures {
                if (auto self = weak.lock()) {
                    return impl.getTile(id.z, id.x, id.y).features;
                }
                return {};
            },
            fn);
```

It caused program termination in case `self` turned to be the last reference to `this`,
as the `std::thread` destructor was called from the thread it represented.

Now, only the `GeoJSONVTData::impl` class member is retained.
@pozdnyakov pozdnyakov added the Core The cross-platform C++ core, aka mbgl label Jan 9, 2020
@pozdnyakov pozdnyakov self-assigned this Jan 9, 2020
@captainbarbosa
Copy link
Contributor

A bit of feedback - it would be greatly helpful if these kinds of changes could be summarized with an easy to digest summary that can be used by the respective downstream platform teams. Otherwise, we end up trying to make a best guess on what changes mean, which leaves room for misinterpretation when we write our changelogs.

@zugaldia
Copy link
Member

Agreed w/ @captainbarbosa above. If a CHANGELOG entry isn't possible at this stage, a proposed entry would be a good alternative. This helps expedite downstream releases, particularly in cases where we need to cherry pick changes for a patch releases. Thanks! cc: @chloekraw @tmpsantos

@alexshalamov alexshalamov added the needs changelog Indicates PR needs a changelog entry prior to merging. label Jan 10, 2020
@alexshalamov
Copy link
Contributor

@pozdnyakov could you please add changelog entry for this PR? thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl needs changelog Indicates PR needs a changelog entry prior to merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash with release-tequila
4 participants