Skip to content

Commit 86cbc2b

Browse files
author
Dianne Hackborn
committed
Work on issue #22765972: Binder transactions running out of address...
...space causing package manager to fail Lower the maximum IPC size we use in various places, to keep it under the threshold of becoming dangerous. Now everything tries to keep not much more than 64k. Change-Id: I814013097966a7843179e5d581bfdb254c5ae318
1 parent 3551a59 commit 86cbc2b

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

core/java/android/app/assist/AssistStructure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ boolean writeToParcelInner(AssistStructure as, Parcel out) {
141141
if (DEBUG_PARCEL) Log.d(TAG, "Creating PooledStringWriter @ " + out.dataPosition());
142142
PooledStringWriter pwriter = new PooledStringWriter(out);
143143
while (writeNextEntryToParcel(as, out, pwriter)) {
144-
// If the parcel contains more than 100K of data, then we are getting too
144+
// If the parcel is above the IPC limit, then we are getting too
145145
// large for a single IPC so stop here and let the caller come back when it
146146
// is ready for more.
147-
if (out.dataSize() > 1024*1024) {
147+
if (out.dataSize() > IBinder.MAX_IPC_SIZE) {
148148
if (DEBUG_PARCEL) Log.d(TAG, "Assist data size is " + out.dataSize()
149149
+ " @ pos " + out.dataPosition() + "; returning partial result");
150150
out.writeInt(0);

core/java/android/content/pm/ParceledListSlice.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ public class ParceledListSlice<T extends Parcelable> implements Parcelable {
4646
* TODO get this number from somewhere else. For now set it to a quarter of
4747
* the 1MB limit.
4848
*/
49-
private static final int MAX_IPC_SIZE = 256 * 1024;
50-
private static final int MAX_FIRST_IPC_SIZE = MAX_IPC_SIZE / 2;
49+
private static final int MAX_IPC_SIZE = IBinder.MAX_IPC_SIZE;
5150

5251
private final List<T> mList;
5352

@@ -150,7 +149,7 @@ public void writeToParcel(Parcel dest, int flags) {
150149
final Class<?> listElementClass = mList.get(0).getClass();
151150
dest.writeParcelableCreator(mList.get(0));
152151
int i = 0;
153-
while (i < N && dest.dataSize() < MAX_FIRST_IPC_SIZE) {
152+
while (i < N && dest.dataSize() < MAX_IPC_SIZE) {
154153
dest.writeInt(1);
155154

156155
final T parcelable = mList.get(i);

core/java/android/os/IBinder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ public interface IBinder {
149149
* processes.
150150
*/
151151
int FLAG_ONEWAY = 0x00000001;
152-
152+
153+
/**
154+
* Limit that should be placed on IPC sizes to keep them safely under the
155+
* transaction buffer limit.
156+
* @hide
157+
*/
158+
public static final int MAX_IPC_SIZE = 64 * 1024;
159+
153160
/**
154161
* Get the canonical name of the interface supported by this binder.
155162
*/

0 commit comments

Comments
 (0)