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

Commit e11025f9 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

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

Change-Id: Icf270c6b8ff76d5c6b23ddba1f1b426fef13e0ff
parents fc83d13b bbcdbdd9
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());