diff options
author | Martijn Coenen <maco@google.com> | 2021-10-04 09:19:01 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2022-02-03 16:14:47 +0100 |
commit | 1cad19cfed5b3be0d8ccc1170cd0077bbeea6fa8 (patch) | |
tree | fccb7a3ff81388fbe258beaff84903594ad595b9 | |
parent | 95f9945cb2675005b31179fa278baa24eef94fbd (diff) | |
download | native-1cad19cfed5b3be0d8ccc1170cd0077bbeea6fa8.tar.gz |
Log outgoing transactions/replies over 300kB.
There's some occurences of a transaction just under 1 MB into
system_server, which causes system_server to reject other transactions,
and sometimes throw DeadSystemException.
Until we have better backend infrastructure in place, at least log the
source and some data of really large transactions, which might give us
some sort of clue.
Bug: 198380036
Bug: 213349547
Test: N/A
Change-Id: Ifccf4a2dea32cd43421b61d3003d2a2bdc86ee23
-rw-r--r-- | libs/binder/Binder.cpp | 6 | ||||
-rw-r--r-- | libs/binder/BpBinder.cpp | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index ec9d5544f9..0970ca5aa5 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -54,6 +54,8 @@ constexpr const bool kEnableRpcDevServers = true; constexpr const bool kEnableRpcDevServers = false; #endif +// Log any reply transactions for which the data exceeds this size +#define LOG_REPLIES_OVER_SIZE (300 * 1024) // --------------------------------------------------------------------------- IBinder::IBinder() @@ -296,6 +298,10 @@ status_t BBinder::transact( // In case this is being transacted on in the same process. if (reply != nullptr) { reply->setDataPosition(0); + if (reply->dataSize() > LOG_REPLIES_OVER_SIZE) { + ALOGW("Large reply transaction of %zu bytes, interface descriptor %s, code %d", + reply->dataSize(), String8(getInterfaceDescriptor()).c_str(), code); + } } return err; diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index 06542f064d..056ef0ab74 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -48,6 +48,9 @@ uint32_t BpBinder::sBinderProxyCountHighWatermark = 2500; // Another arbitrary value a binder count needs to drop below before another callback will be called uint32_t BpBinder::sBinderProxyCountLowWatermark = 2000; +// Log any transactions for which the data exceeds this size +#define LOG_TRANSACTIONS_OVER_SIZE (300 * 1024) + enum { LIMIT_REACHED_MASK = 0x80000000, // A flag denoting that the limit has been reached COUNTING_VALUE_MASK = 0x7FFFFFFF, // A mask of the remaining bits for the count value @@ -302,6 +305,14 @@ status_t BpBinder::transact( } else { status = IPCThreadState::self()->transact(binderHandle(), code, data, reply, flags); } + if (data.dataSize() > LOG_TRANSACTIONS_OVER_SIZE) { + Mutex::Autolock _l(mLock); + ALOGW("Large outgoing transaction of %zu bytes, interface descriptor %s, code %d", + data.dataSize(), + mDescriptorCache.size() ? String8(mDescriptorCache).c_str() + : "<uncached descriptor>", + code); + } if (status == DEAD_OBJECT) mAlive = 0; |