libbinder: add log for dropped extension
In the NDK/Rust backend, it's pretty easy to create a binder, attach
an extension to it, and then immediately destroy that binder.
Here, I add a log when this happens and add a unit test for BBinder
which triggers this path (it's never expected to be hit in practice
since binders aren't created without being sent).
Bug: N/A
Test: binderUnitTests
Change-Id: Id2b51396b027530e3fad767f698a3b2cecbfa98d
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index 01b25d3..39befbe 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -582,6 +582,10 @@
BBinder::~BBinder()
{
+ if (!wasParceled() && getExtension()) {
+ ALOGW("Binder %p destroyed with extension attached before being parceled.", this);
+ }
+
Extras* e = mExtras.load(std::memory_order_relaxed);
if (e) delete e;
}