Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e31c3fb authored by Steven Moreland's avatar Steven Moreland
Browse files

OutOfMemoryError: print Parcel size

OOM can be caused by many reasons. Print the exact
parcel size, as this is all the information
at this layer.

This helps because:
- it makes clear OOM is from this exact throw.
- if the Parcel size is small, it hints to
  a server side issue that leads to OOM.

Bug: 404210068
Test: create OOM, check logs and see error message
Change-Id: I4129ae29f546d60ffbcfd30058bf899b43fa8541
parent 97940816
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1028,9 +1028,17 @@ void signalExceptionForError(JNIEnv* env, jobject obj, status_t err,
        case UNKNOWN_ERROR:
            jniThrowException(env, "java/lang/RuntimeException", "Unknown error");
            break;
        case NO_MEMORY:
            jniThrowException(env, "java/lang/OutOfMemoryError", NULL);
        case NO_MEMORY: {
            // Often this is from the server using too much memory or
            // some other ENOMEM case in libbinder (such as doing an operation
            // that is expected to pass the binder buffer). If we are really
            // out of memory here and cannot allocate this string, it's okay
            // to just crash, as the whole system is going down.
            String8 msg;
            msg.appendFormat("During transaction with Parcel size %d.", parcelSize);
            jniThrowException(env, "java/lang/OutOfMemoryError", msg.c_str());
            break;
        }
        case INVALID_OPERATION:
            jniThrowException(env, "java/lang/UnsupportedOperationException", NULL);
            break;