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

Commit bd98e0f0 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: use after fork aborts

This is a separate CL, since the warning is independently useful, even
if this needs to be reverted.

Fixes: 202289725
Test: binderLibTest
Change-Id: Ifb046f01cee047d1908a69c075a66ecb0bc68a78
parent ee9df901
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());