Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2aa78cbe authored by Rob Carr's avatar Rob Carr
Browse files

SurfaceFlinger: Avoid overlapping calls to BOOT_FINISHED

Handling BOOT_FINISHED we write to mInputFlinger and mWindowManager.
This could trigger crashes if we write from multiple concurrent threads
or if we try and use it from the main thread while decing the strong
pointer. The easiest way to work around this seems to just to only
be willing to handle BOOT_FINISHED once, until the WM dies.

Bug: 150227563
Bug: 150225569
Test: Existing tests pass
Change-Id: I10f4b9359a5f3dc49e3360f28fbe808f0fc2afc8
parent 7190e99b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -409,6 +409,7 @@ SurfaceFlinger::~SurfaceFlinger() = default;
void SurfaceFlinger::binderDied(const wp<IBinder>& /* who */)
{
    // the window manager died on us. prepare its eulogy.
    mBootFinished = false;

    // restore initial conditions (default device unblank, etc)
    initializeDisplays();
@@ -525,6 +526,11 @@ compositionengine::CompositionEngine& SurfaceFlinger::getCompositionEngine() con

void SurfaceFlinger::bootFinished()
{
    if (mBootFinished == true) {
        ALOGE("Extra call to bootFinished");
        return;
    }
    mBootFinished = true;
    if (mStartPropertySetThread->join() != NO_ERROR) {
        ALOGE("Join StartPropertySetThread failed!");
    }
+4 −0
Original line number Diff line number Diff line
@@ -1129,6 +1129,10 @@ private:

    // to linkToDeath
    sp<IBinder> mWindowManager;
    // We want to avoid multiple calls to BOOT_FINISHED as they come in on
    // different threads without a lock and could trigger unsynchronized writes to
    // to mWindowManager or mInputFlinger
    std::atomic<bool> mBootFinished = false;

    std::unique_ptr<dvr::VrFlinger> mVrFlinger;
    std::atomic<bool> mVrFlingerRequestsDisplay = false;