Skip to content

Fix crash on HTC One M8#1

Open
ahamilt wants to merge 1 commit intomulti-os-engine:masterfrom
ahamilt:annotationMethodCallBug
Open

Fix crash on HTC One M8#1
ahamilt wants to merge 1 commit intomulti-os-engine:masterfrom
ahamilt:annotationMethodCallBug

Conversation

@ahamilt
Copy link

@ahamilt ahamilt commented Nov 17, 2016

There appears to be a bug on the HTC One M8, described here:

https://code.google.com/p/android/issues/detail?id=190058

Calls to methods on Annotations attempt to read parmaeters that
should not be there, resulting in "use of invalid jobject" error.
This affects libnatj.so, when NatJ.register() is called
the process crashes. Extract from log included below.

This bug looks like it is fixed in ASOP, but unfortunately
not in the HTC ROM (tested with the latest OTA ROM
available on this device, 6.12.161.4. Later firmware
versions are available from different carriers and for
manual download / install, I have not tested these).

The workaround described in the issue above prevents the crash.
This commit applies the workaround to CRuntime.cpp.

11-17 09:32:28.434 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448] JNI DETECTED ERROR IN APPLICATION: use
of invalid jobject 0xb38d2070
11-17 09:32:28.434 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448] from void
org.moe.natj.c.CRuntime.registerClass(java.lang.Class)
...
11-17 09:32:28.435 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448] native: #9 pc 0000acb1
/data/app/myapplication.dev-1/lib/arm/libnatj.so
(_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...)+28)
11-17 09:32:28.435 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448] native: #10 pc 0000e0ef
/data/app/myapplication.dev-1/lib/arm/libnatj.so
(processStructureFunctions(_JNIEnv*, _jclass*)+814)

There appears to be a bug on the HTC One M8, described here:

https://code.google.com/p/android/issues/detail?id=190058

Calls to methods on Annotations attempt to read parmaeters that
should not be there, resulting in "use of invalid jobject" error.
This affects libnatj.so, when NatJ.register() is called
the process crashes. Extract from log included below.

This bug looks like it is fixed in ASOP, but unfortunately
not in the HTC ROM (tested with the latest OTA ROM
available on this device, 6.12.161.4. Later firmware
versions are available from different carriers and for
manual download / install, I have not tested these).

The workaround described in the issue above prevents the crash.
This commit applies the workaround to CRuntime.cpp.

11-17 09:32:28.434 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448] JNI DETECTED ERROR IN APPLICATION: use
of invalid jobject 0xb38d2070
11-17 09:32:28.434 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448]     from void
org.moe.natj.c.CRuntime.registerClass(java.lang.Class)
...
11-17 09:32:28.435 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448]   native: multi-os-engine#9 pc 0000acb1
/data/app/myapplication.dev-1/lib/arm/libnatj.so
(_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...)+28)
11-17 09:32:28.435 28187-28187/myapplication.dev A/art:
art/runtime/java_vm_ext.cc:448]   native: multi-os-engine#10 pc 0000e0ef
/data/app/myapplication.dev-1/lib/arm/libnatj.so
(processStructureFunctions(_JNIEnv*, _jclass*)+814)
@kisg
Copy link
Contributor

kisg commented Nov 23, 2016

First, I would like to thank you for taking the time creating this pull request.

However, I am not sure if we should add this workaround, because it may break other VMs, e.g. Oracle VM.

I would like to see a solution where the workaround is only applied if the buggy ART runtime is detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments