summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Devin Moore <devinmoore@google.com> 2021-07-02 13:03:49 -0700
committer Steven Moreland <smoreland@google.com> 2021-07-12 21:09:00 +0000
commit082564349e21530a78d569547dea7971a2381562 (patch)
treede96c3119245d22b939025a8b9dfceb3238f78bd /libs
parent2bfbdffc26b4da2670a74b8fef640fa3741ad229 (diff)
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
Diffstat (limited to 'libs')
-rw-r--r--libs/binder/RpcState.cpp7
-rw-r--r--libs/binder/RpcState.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index b5eaaa3413..5881703752 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -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);
diff --git a/libs/binder/RpcState.h b/libs/binder/RpcState.h
index 8201eba5da..5ac0b973f1 100644
--- a/libs/binder/RpcState.h
+++ b/libs/binder/RpcState.h
@@ -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