Skip to content

Commit 31360ae

Browse files
committed
rust_binder: Implement the BINDER_DEBUG_DEAD_TRANSACTION
logging mask to trace in-flight cancellations during teardown This adds dynamic debug logs for: - Releasing active transactions during thread stack unwinding. - Discarded transaction error codes when a thread exits. - Undelivered transaction acknowledgments (TRANSACTION_COMPLETE) upon thread exit. - Undelivered process death and freeze notifications when processes exit or die. - Undelivered transactions canceled due to target process death. Change-Id: Iad322cb89497087dfc9e1d52850cf74afb55b6b5 Signed-off-by: Jahnavi MN <jahnavimn@google.com>
1 parent 2b637d4 commit 31360ae

5 files changed

Lines changed: 44 additions & 5 deletions

File tree

drivers/android/binder/freeze.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ impl DeliverToRead for FreezeMessage {
140140
}
141141
}
142142

143-
fn cancel(self: DArc<Self>) {}
143+
fn cancel(self: DArc<Self>) {
144+
binder_debug!(
145+
DeadTransaction,
146+
"undelivered freeze notification, {:016x}",
147+
self.cookie.0
148+
);
149+
}
144150

145151
fn should_sync_wakeup(&self) -> bool {
146152
false

drivers/android/binder/node.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,13 @@ impl DeliverToRead for NodeDeath {
11231123
Ok(cmd != BR_DEAD_BINDER)
11241124
}
11251125

1126-
fn cancel(self: DArc<Self>) {}
1126+
fn cancel(self: DArc<Self>) {
1127+
binder_debug!(
1128+
DeadTransaction,
1129+
"undelivered death notification, {:016x}",
1130+
self.cookie
1131+
);
1132+
}
11271133

11281134
fn should_sync_wakeup(&self) -> bool {
11291135
false

drivers/android/binder/rust_binder_main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,14 @@ impl DeliverToRead for DeliverCode {
257257
Ok(true)
258258
}
259259

260-
fn cancel(self: DArc<Self>) {}
260+
fn cancel(self: DArc<Self>) {
261+
if !self.skip.load(Relaxed) {
262+
binder_debug!(
263+
DeadTransaction,
264+
"undelivered TRANSACTION_COMPLETE"
265+
);
266+
}
267+
}
261268

262269
fn should_sync_wakeup(&self) -> bool {
263270
false

drivers/android/binder/thread.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,13 @@ impl Thread {
11601160
let mut inner = thread.inner.lock();
11611161
inner.pop_transaction_to_reply(thread.as_ref())
11621162
} {
1163+
binder_debug!(
1164+
DeadTransaction,
1165+
"release process {} transaction {} in, still active",
1166+
self.process.task.pid(),
1167+
transaction.debug_id
1168+
);
1169+
11631170
let reply = Err(BR_DEAD_REPLY);
11641171
if !transaction
11651172
.from
@@ -1235,7 +1242,6 @@ impl Thread {
12351242
inner.push_reply_work(code)
12361243
}
12371244
}
1238-
}
12391245
};
12401246

12411247
// Notify the thread now that we've released the inner lock.
@@ -1754,7 +1760,15 @@ impl DeliverToRead for ThreadError {
17541760
Ok(true)
17551761
}
17561762

1757-
fn cancel(self: DArc<Self>) {}
1763+
fn cancel(self: DArc<Self>) {
1764+
let code = self.error_code.load(Relaxed);
1765+
if code != BR_OK {
1766+
binder_debug!(
1767+
DeadTransaction,
1768+
"undelivered TRANSACTION_ERROR: {code}"
1769+
);
1770+
}
1771+
}
17581772

17591773
fn should_sync_wakeup(&self) -> bool {
17601774
false

drivers/android/binder/transaction.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,12 @@ impl DeliverToRead for Transaction {
534534
if self.target_node.is_some() && self.flags & TF_ONE_WAY == 0 {
535535
let reply = Err(BR_DEAD_REPLY);
536536
self.from.deliver_reply(reply, &self, None);
537+
} else {
538+
binder_debug!(
539+
DeadTransaction,
540+
"undelivered transaction {}, process died",
541+
self.debug_id
542+
);
537543
}
538544

539545
self.drop_outstanding_txn();

0 commit comments

Comments
 (0)