From a433556fc07feed84f18ff050428e3edf4fd9e22 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Tue, 28 Jun 2022 20:27:46 +0000 Subject: [PATCH] Fix crash due to race on close() It's possible for close to be called during local cleanup concurrently with the remote call. A recent change (ag/15993920) added a missing Binder.unlinkToDeath call to close(). This now causes a crash now if the registration was removed at just the right time in another thread. This synchronizes access to close() to avoid this. Bug: 237406501 Test: atest ScrollCaptureConnectionTest Change-Id: I0126bfac1efdece2e4eff144a44f29a963553b74 --- core/java/android/view/ScrollCaptureConnection.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/ScrollCaptureConnection.java b/core/java/android/view/ScrollCaptureConnection.java index d70de74ee75f4..c50f70a08063d 100644 --- a/core/java/android/view/ScrollCaptureConnection.java +++ b/core/java/android/view/ScrollCaptureConnection.java @@ -214,7 +214,7 @@ public class ScrollCaptureConnection extends IScrollCaptureConnection.Stub imple @BinderThread @Override - public void close() { + public synchronized void close() { Trace.instantForTrack(TRACE_TAG_GRAPHICS, TRACE_TRACK, "close"); if (mActive) { Log.w(TAG, "close(): capture session still active! Ending now.");