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

Commit 5b231684 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder: use after fork aborts" am: 8cd66763 am: bbcdbdd9 am: e11025f9

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1858428

Change-Id: I5c817746779c4e02f084a1d4c39c44a58f0c3bf4
parents 02285842 e11025f9
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -93,9 +93,7 @@ sp<ProcessState> ProcessState::selfOrNull()
[[clang::no_destroy]] static std::mutex gProcessMutex;

static void verifyNotForked(bool forked) {
    if (forked) {
        ALOGE("libbinder does not support being forked");
    }
    LOG_ALWAYS_FATAL_IF(forked, "libbinder ProcessState can not be used after fork");
}

sp<ProcessState> ProcessState::init(const char *driver, bool requireDefault)
+5 −0
Original line number Diff line number Diff line
@@ -436,6 +436,11 @@ class TestDeathRecipient : public IBinder::DeathRecipient, public BinderLibTestE
        };
};

TEST_F(BinderLibTest, CannotUseBinderAfterFork) {
    // EXPECT_DEATH works by forking the process
    EXPECT_DEATH({ ProcessState::self(); }, "libbinder ProcessState can not be used after fork");
}

TEST_F(BinderLibTest, WasParceled) {
    auto binder = sp<BBinder>::make();
    EXPECT_FALSE(binder->wasParceled());