Skip to content

Commit 19f2274

Browse files
Mattias PeterssonJohan Redestig
authored andcommitted
Prevent system crash when OOM in Binder thread.
When handling large images during an update of a widget, we can run out of memory in the Binder thread. This will cause an OutOfMemoryError to be thrown. When an Error is thrown in the Binder thread, the entire system will crash. This was fixed by catching this OutOfMemoryError and instead throw a RuntimeException to keep the system alive. Change-Id: If27199676c6f8aef23fb249be1197ca5dfe0fe99
1 parent 5580e44 commit 19f2274

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/java/android/os/Binder.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ private boolean execTransact(int code, int dataObj, int replyObj,
292292
} catch (RuntimeException e) {
293293
reply.writeException(e);
294294
res = true;
295+
} catch (OutOfMemoryError e) {
296+
RuntimeException re = new RuntimeException("Out of memory", e);
297+
reply.writeException(re);
298+
res = true;
295299
}
296300
reply.recycle();
297301
data.recycle();

0 commit comments

Comments
 (0)