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

Commit 2ff0d47c authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: RPC avoid server shutdown crash

Server thread needs to detach itself before removing its entry in
RpcSession. This was causing the (upcoming) RPC server fuzzer to fail
very frequently.

Bug: 182938024
Test: w/ fuzzer, binderRpcTest
Change-Id: I004747971997ed2ae90613757836eb6f68473abd
parent ee78e760
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -143,8 +143,10 @@ void RpcSession::startThread(unique_fd client) {
        holdThis->join(unique_fd(fd));
        {
            std::lock_guard<std::mutex> _l(holdThis->mMutex);
            size_t erased = mThreads.erase(std::this_thread::get_id());
            LOG_ALWAYS_FATAL_IF(erased != 0, "Could not erase thread.");
            auto it = mThreads.find(std::this_thread::get_id());
            LOG_ALWAYS_FATAL_IF(it == mThreads.end());
            it->second.detach();
            mThreads.erase(it);
        }
    });
    mThreads[thread.get_id()] = std::move(thread);