Merge "WTF Logging for catching memory issue in Parcel" into oc-dev
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 28bdacf..c5c743b 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -427,7 +427,13 @@
* @param size The new number of bytes in the Parcel.
*/
public final void setDataSize(int size) {
- updateNativeSize(nativeSetDataSize(mNativePtr, size));
+ // STOPSHIP: Try/catch for exception is for temporary debug. Remove once bug resolved
+ try {
+ updateNativeSize(nativeSetDataSize(mNativePtr, size));
+ } catch (IllegalArgumentException iae) {
+ Log.e(TAG,"Caught Exception representing a known bug in Parcel",iae);
+ Log.wtfStack(TAG, "This flow is using SetDataSize incorrectly");
+ }
}
/**
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index d740a76..56f68d4 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -119,7 +119,11 @@
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
const status_t err = parcel->setDataSize(size);
- if (err != NO_ERROR) {
+ //STOPSHIP: check for BADFLO is for a temporary debug using wtf. Remove once bug resolved.
+ if (err == UNKNOWN_ERROR + 0xBADF10) {
+ jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException",
+ "Attempt to resize (size = %d) Parcel would corrupt object memory", size);
+ } else if (err != NO_ERROR) {
signalExceptionForError(env, clazz, err);
}
return parcel->getOpenAshmemSize();