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

Commit 08256434 authored by Devin Moore's avatar Devin Moore Committed by Steven Moreland
Browse files

libbinder: RPC flake mode fix

The #ifdef should be #if because RPC_FLAKE_PRONE is defined to false.
[[clang::no_destroy]] is needed for the static variables in
rpcMaybeWaitToFlake otherwise it can crash for taking a mutex that was
destroyed in the onLastStrongRef->sendDecStrong path.

Test: atest binderRpcTest
Fixes: 190828148
Change-Id: Iac6302d737de70f5fde2656dd2e140a6dcd13f7e
parent 2bfbdffc
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -34,11 +34,10 @@ namespace android {

using base::ScopeGuard;

#ifdef RPC_FLAKE_PRONE
#if RPC_FLAKE_PRONE
void rpcMaybeWaitToFlake() {
    static std::random_device r;
    static std::mutex m;

    [[clang::no_destroy]] static std::random_device r;
    [[clang::no_destroy]] static std::mutex m;
    unsigned num;
    {
        std::lock_guard<std::mutex> lock(m);
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ struct RpcWireHeader;

#define RPC_FLAKE_PRONE false

#ifdef RPC_FLAKE_PRONE
#if RPC_FLAKE_PRONE
void rpcMaybeWaitToFlake();
#define MAYBE_WAIT_IN_FLAKE_MODE rpcMaybeWaitToFlake()
#else