From 5704271e43f984fe5ca8b547205378852599be7c Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 4 Oct 2022 23:56:45 +0000 Subject: 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 --- libs/binder/tests/binderRpcTest.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 652da991a4..499fdd2773 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -181,10 +181,20 @@ struct ProcessSession { wp weakSession = session; session = nullptr; - sp 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 strongSession = weakSession.promote(); + EXPECT_EQ(nullptr, strongSession) + << (debugBacktrace(host.getPid()), debugBacktrace(getpid()), + "Leaked sess: ") + << strongSession->getStrongCount() << " checked time " << i; + + if (strongSession != nullptr) { + sleep(1); + } + } } } }; -- cgit v1.2.3-59-g8ed1b