binderRpcTest: session leak investigation part IV
Repros in infra every once in a while, local repro
reported w/ concurrent build, but unable to repro
overnight.
Bug: 244325464
Test: binderRpcTest
Change-Id: I07a173dd3b670d5dd80fc37eb9819ede7d305aa6
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp
index 652da99..499fdd2 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -181,10 +181,20 @@
wp<RpcSession> weakSession = session;
session = nullptr;
- sp<RpcSession> strongSession = weakSession.promote();
- EXPECT_EQ(nullptr, strongSession)
- << (debugBacktrace(host.getPid()), debugBacktrace(getpid()), "Leaked sess: ")
- << strongSession->getStrongCount();
+ // b/244325464 - 'getStrongCount' is printing '1' on failure here, which indicates the
+ // the object should not actually be promotable. By looping, we distinguish a race here
+ // from a bug causing the object to not be promotable.
+ for (size_t i = 0; i < 3; i++) {
+ sp<RpcSession> strongSession = weakSession.promote();
+ EXPECT_EQ(nullptr, strongSession)
+ << (debugBacktrace(host.getPid()), debugBacktrace(getpid()),
+ "Leaked sess: ")
+ << strongSession->getStrongCount() << " checked time " << i;
+
+ if (strongSession != nullptr) {
+ sleep(1);
+ }
+ }
}
}
};