Avoid calling flushCommands in BpBinder::onLastStrongRef
BpBinder::onLastStrongRef calls removeFrozenStateChangeCallback which in turn calls flushCommands. This can cause BpBinder to be freed twice due to this invocation chain: processPostWriteDerefs -> decStrong -> onLastStrongRef -> removeFrozenStateChangeCallback -> talkWithDriver -> processPostWriteDerefs -> decStrong. The recursive call to processPostWriteDerefs causes decStrong to be called the second time erroneously on a BpBinder object. This change fixes the issue by avoiding calling flushCommands in removeFrozenStateChangeCallback when called from BpBinder::onLastStrongRef. The behavior change is guarded behind flag RELEASE_LIBBINDER_NO_FLUSH_ON_LAST_REF Flag: build.RELEASE_LIBBINDER_NO_FLUSH_ON_LAST_REF Bug: 430341301 Test: atest binderLibTest Change-Id: Ic45b75a2b3ebb56c7a9c5ecfafcd8e95ab2e4405
Loading
Please register or sign in to comment