Mir

Merge lp://qastaging/~afrantzis/mir/fix-1513901-shutdown-crash-with-mesa-kms into lp://qastaging/mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 3094
Proposed branch: lp://qastaging/~afrantzis/mir/fix-1513901-shutdown-crash-with-mesa-kms
Merge into: lp://qastaging/mir
Diff against target: 171 lines (+41/-21)
6 files modified
src/include/platform/mir/emergency_cleanup_registry.h (+4/-1)
src/platforms/mesa/server/kms/platform.cpp (+10/-8)
src/server/default_emergency_cleanup.cpp (+11/-2)
src/server/default_emergency_cleanup.h (+2/-1)
tests/include/mir/test/doubles/null_emergency_cleanup.h (+1/-0)
tests/unit-tests/graphics/mesa/kms/test_platform.cpp (+13/-9)
To merge this branch: bzr merge lp://qastaging/~afrantzis/mir/fix-1513901-shutdown-crash-with-mesa-kms
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Andreas Pokorny (community) Approve
Alan Griffiths Approve
Review via email: mp+276986@code.qastaging.launchpad.net

Commit message

platform: Platform emergency cleanup handlers should keep platform modules alive

Otherwise, the cleanup handler destructor (which is part of the platform shared
object code) may be called after the platform shared object has been unloaded,
leading to a crash.

Description of the change

platform: Platform emergency cleanup handlers should keep platform modules alive

Otherwise, the cleanup handler destructor (which is part of the platform shared object code) may be called after the platform shared object has been unloaded, leading to a crash.

Note that the changes in this MP break the platform ABI, but the ABI has already been bumped after 0.17.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Fixes the problem.

It seems a shame to add yet a further level of indirection (and memory allocation) to std::function<> but this only costs during startup/shutdown, so OK.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Fixes the problem.
>
> It seems a shame to add yet a further level of indirection (and memory
> allocation) to std::function<> but this only costs during startup/shutdown, so
> OK.

Hm there is a proposal for a std::function with allocator..

Couldnt we store alive-keeping inside the bound functor. (Downside: Moves responsibility of being aware of the problem and dealing with it properly to the caller/platform author.. ).

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I meant:
     emergency_cleanup_registry.add(
        [weak_vt, weak_drm, keep_library_alive=mir::detail::RefCountedLibrary(reinterpret_cast<void*>(&create_host_platform))]
        {
            if (auto const vt = weak_vt.lock())
                try { vt->restore(); } catch (...) {}

            if (auto const drm = weak_drm.lock())
                try { drm->drop_master(); } catch (...) {}
 });

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> keep_library_alive=mir::detail::RefCountedLibrary(reinterpret_cast<void*>(&create_host_platform))]

This what I tried first (although I used a shared_ptr<> backed by mir::UniqueModulePtr<int> as the keep_alive object) but it didn't have the desired result. I also tried your proposal (RefCountedLibrary) a moment ago without success either.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

oh you might then have the problem that the destructor code is unloaded while being executed.. since it is part of the lambda object inside the platform library...

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches