Bug 52733 - JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String
Summary: JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-02-24 04:25 UTC by Jared Kells
Modified: 2017-06-27 18:31 UTC (History)
4 users (show)

See Also:
Tags: Cycle9R, bb
Is this bug a regression?: ---
Last known good build:


Attachments
Reproduction (1.48 KB, text/plain)
2017-04-20 03:15 UTC, Jared Kells
Details
Sample project demonstrating the issue (29.53 KB, application/zip)
2017-06-27 18:28 UTC, Tom Opgenorth
Details
Contents of the Application Output pad with the error. (101.72 KB, text/plain)
2017-06-27 18:31 UTC, Tom Opgenorth
Details

Description Jared Kells 2017-02-24 04:25:21 UTC
Hi,

Running Cycle 9 on a Nexus 6P, API level 24 in debug mode crashes with JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String

The application gets to a different point each time, I can get as far as an activity being created before it crashes. Sometimes there is some of our code in the one of the thread stacks, but it's always different.

Switching the GC from tarjan back to old fixes the issue.

Running the same project on Galaxy S5 running API 23 doesn't crash.

Attached below is one of the crashes.


02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]     in call to CallStaticObjectMethod
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] "Thread-10" prio=5 tid=23 Runnable
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | group="main" sCount=0 dsCount=0 obj=0x12cf0280 self=0x77e0595c00
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | sysTid=7062 nice=0 cgrp=default sched=0/0 handle=0x77df3ff450
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | state=R schedstat=( 58442756 9069225 370 ) utm=4 stm=1 core=3 HZ=100
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | stack=0x77df201000-0x77df203000 stackSize=2045KB
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | held mutexes= "mutator lock"(shared held)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #00 pc 000000000047e090  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #01 pc 000000000047e08c  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #02 pc 00000000004521f8  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #03 pc 00000000002f03e4  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1136)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #04 pc 00000000002f0af4  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+124)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #05 pc 0000000000102718  /system/lib64/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+156)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #06 pc 0000000000101d04  /system/lib64/libart.so (_ZN3art11ScopedCheck13CheckInstanceERNS_18ScopedObjectAccessENS0_12InstanceKindEP8_jobjectb+880)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #07 pc 00000000000ffc68  /system/lib64/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE+1124)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #08 pc 00000000001055e4  /system/lib64/libart.so (_ZN3art8CheckJNI13CheckCallArgsERNS_18ScopedObjectAccessERNS_11ScopedCheckEP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDNS_10InvokeTypeEPKNS_7VarArgsE+140)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #09 pc 00000000001048a0  /system/lib64/libart.so (_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDSt9__va_listNS_9Primitive4TypeENS_10InvokeTypeE+704)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #10 pc 00000000000f8b48  /system/lib64/libart.so (_ZN3art8CheckJNI22CallStaticObjectMethodEP7_JNIEnvP7_jclassP10_jmethodIDz+160)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #11 pc 000000000001386c  /data/app/com.criticalarc.safezoneapp-1/lib/arm64/libmonodroid.so (???)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   (no managed stack frames)
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] 
02-24 13:14:58.890 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]     in call to CallStaticObjectMethod
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] "Thread-9" prio=5 tid=22 Runnable
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | group="main" sCount=0 dsCount=0 obj=0x12cf01f0 self=0x77fd8e2200
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | sysTid=7061 nice=0 cgrp=default sched=0/0 handle=0x77df9fe450
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | state=R schedstat=( 65826861 9904328 320 ) utm=3 stm=2 core=1 HZ=100
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | stack=0x77df800000-0x77df802000 stackSize=2045KB
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | held mutexes= "mutator lock"(shared held)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #00 pc 000000000047e090  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #01 pc 000000000047e08c  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #02 pc 00000000004521f8  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #03 pc 00000000002f03e4  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1136)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #04 pc 00000000002f0af4  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+124)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #05 pc 0000000000102718  /system/lib64/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+156)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #06 pc 0000000000101d04  /system/lib64/libart.so (_ZN3art11ScopedCheck13CheckInstanceERNS_18ScopedObjectAccessENS0_12InstanceKindEP8_jobjectb+880)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #07 pc 00000000000ffc68  /system/lib64/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE+1124)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #08 pc 00000000001055e4  /system/lib64/libart.so (_ZN3art8CheckJNI13CheckCallArgsERNS_18ScopedObjectAccessERNS_11ScopedCheckEP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDNS_10InvokeTypeEPKNS_7VarArgsE+140)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #09 pc 00000000001048a0  /system/lib64/libart.so (_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDSt9__va_listNS_9Primitive4TypeENS_10InvokeTypeE+704)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #10 pc 00000000000f8b48  /system/lib64/libart.so (_ZN3art8CheckJNI22CallStaticObjectMethodEP7_JNIEnvP7_jclassP10_jmethodIDz+160)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #11 pc 000000000001386c  /data/app/com.criticalarc.safezoneapp-1/lib/arm64/libmonodroid.so (???)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   (no managed stack frames)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] 
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]     in call to CallStaticObjectMethod
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] "Thread-8" prio=5 tid=21 Runnable
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | group="main" sCount=0 dsCount=0 obj=0x12cf0160 self=0x77e056d800
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | sysTid=7060 nice=0 cgrp=default sched=0/0 handle=0x77dfbff450
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | state=R schedstat=( 66964429 7520523 397 ) utm=4 stm=2 core=0 HZ=100
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | stack=0x77dfa01000-0x77dfa03000 stackSize=2045KB
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   | held mutexes= "mutator lock"(shared held)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #00 pc 000000000047e090  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #01 pc 000000000047e08c  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #02 pc 00000000004521f8  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+480)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #03 pc 00000000002f03e4  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1136)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #04 pc 00000000002f0af4  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+124)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #05 pc 0000000000102718  /system/lib64/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+156)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #06 pc 0000000000101d04  /system/lib64/libart.so (_ZN3art11ScopedCheck13CheckInstanceERNS_18ScopedObjectAccessENS0_12InstanceKindEP8_jobjectb+880)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #07 pc 00000000000ffc68  /system/lib64/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE+1124)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #08 pc 00000000001055e4  /system/lib64/libart.so (_ZN3art8CheckJNI13CheckCallArgsERNS_18ScopedObjectAccessERNS_11ScopedCheckEP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDNS_10InvokeTypeEPKNS_7VarArgsE+140)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #09 pc 00000000001048a0  /system/lib64/libart.so (_ZN3art8CheckJNI11CallMethodVEPKcP7_JNIEnvP8_jobjectP7_jclassP10_jmethodIDSt9__va_listNS_9Primitive4TypeENS_10InvokeTypeE+704)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #10 pc 00000000000f8b48  /system/lib64/libart.so (_ZN3art8CheckJNI22CallStaticObjectMethodEP7_JNIEnvP7_jclassP10_jmethodIDz+160)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   native: #11 pc 000000000001386c  /data/app/com.criticalarc.safezoneapp-1/lib/arm64/libmonodroid.so (???)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470]   (no managed stack frames)
02-24 13:14:58.891 F/art     ( 6991): art/runtime/java_vm_ext.cc:470] 
02-24 13:14:58.898 D/Mono    ( 6991): Image addref System.ComponentModel[0x77ded5ac80] -> System.ComponentModel.dll[0x77dec30800]: 2
02-24 13:14:58.898 D/Mono    ( 6991): Prepared to set up assembly 'System.ComponentModel' (System.ComponentModel.dll)
02-24 13:14:58.898 D/Mono    ( 6991): Assembly System.ComponentModel[0x77ded5ac80] added to domain RootDomain, ref_count=1
02-24 13:14:58.902 D/Mono    ( 6991): AOT module 'System.ComponentModel.dll.so' not found: dlopen failed: library "/data/app/com.criticalarc.safezoneapp-1/lib/arm64/libaot-System.ComponentModel.dll.so" not found
02-24 13:14:58.906 D/Mono    ( 6991): AOT module '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-aarch64/lib/mono/aot-cache/arm64/System.ComponentModel.dll.so' not found: dlopen failed: library "/data/app/com.criticalarc.safezoneapp-1/lib/arm64/libaot-System.ComponentModel.dll.so" not found
02-24 13:14:58.906 D/Mono    ( 6991): Config attempting to parse: 'System.ComponentModel.dll.config'.
02-24 13:14:58.906 D/Mono    ( 6991): Config attempting to parse: '/Users/builder/data/lanes/4009/f3074d2c/source/monodroid/builds/install/mono-aarch64/etc/mono/assemblies/System.ComponentModel/System.ComponentModel.config'.
02-24 13:14:58.906 D/Mono    ( 6991): Assembly Ref addref Autofac[0x77e3ffc380] -> System.Compone...
Comment 1 Jared Kells 2017-02-24 04:36:06 UTC
Spoke too soon, it's crashing again now even with the old GC bridge.
Comment 2 Jon Goldberger [MSFT] 2017-04-03 20:41:28 UTC
## Bookkeeping note

I will prepare a non-engineering team preliminary quick review for this report.
Comment 3 Jon Goldberger [MSFT] 2017-04-03 20:52:51 UTC
Non-engineering team preliminary quick review
(See https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/ for general reference.)


## Suspected to be a regression or a problem with a new feature?
User reports this occurring with Cycle 9 but did not indicate clearly whether the issue began with Cycle 9, nor was complete version info provided


## Specific to one particular project, development computer, or target mobile device?
Unclear. Issue is described as occurring in one project, but was not necessarily tested against other projects. No code was provided to try to reproduce issue on our end, which may not be possible based on the variability in when the issue occurs, i.e. according to the report: "The application gets to a different point each time, I can get as far as an activity being created before it crashes. Sometimes there is some of our code in the one of the thread stacks, but it's always different."



## Otherwise, likely corresponds to an incorrect behavior in Xamarin or Mono (rather than a usage question, feature request, or enhancement)?
Unclear. As noted sometimes the stack trace includes user code, sometimes not. "Sometimes there is some of our code in the one of the thread stacks, but it's always different."



## Includes clear steps to reproduce the problem?
No. 



## Considers the relevant log files for the part(s) of the process where something goes wrong (IDE editing, MSBuild building, deploying, launching, attaching the debugger, an in-app error, or something else), and has them attached?
Stack trace of one occurrence included in report. 



## Already took up time for many users?
Unclear. This is the only report I have seen of this particular error and there are no users added to the cc list for this bug report



## Makes development (a) difficult, impossible, or potentially hazardous, (b) moderately inconvenient, or (c) mildly inconvenient for users?
(c) as issue does not seem to interfere with development as issue occur (so far) only on Nexus 6P, API level 24 in debug mode.
Comment 4 Jonathan Pryor 2017-04-07 02:01:35 UTC
We would *love* a repro project that demonstrates the issue.
Comment 5 Jared Kells 2017-04-20 03:15:27 UTC
Created attachment 21644 [details]
Reproduction
Comment 6 Jared Kells 2017-04-20 03:25:29 UTC
Hey

I've finally managed to reproduce the error by divide and conquer, please see the attached reproduction.

The issue seems to occur after repeated calls to NetoworkInterface.OperationalStatus. If I call the method a few hundred times in a tight loop I get this crash:
JNI ERROR (app bug): local reference table overflow (max=512)

Calling the method a few hundred times inside a Handler.Post so that the local reference table gets cleared reproduces the original crash:
JNI DETECTED ERROR IN APPLICATION: jclass has wrong type: java.lang.String

Not sure if the two issues are related.

Looking in this file do you need to free networkInterface?
https://github.com/xamarin/xamarin-android/blob/master/src/monodroid/jni/monodroid-networkinfo.c

jobject networkInterface = (*env)->CallStaticObjectMethod (env, NetworkInterface_class, NetworkInterface_getByName, NetworkInterface_nameArg);
Comment 7 Jared Kells 2017-05-08 05:28:32 UTC
Haven't heard anything back for a few weeks was I supposed to change the status on this once I provided a reproduction? 

Changing it from NEEDS INFO -> NEW now in case that's the process.
Comment 8 Tom Opgenorth 2017-06-27 18:28:36 UTC
Created attachment 23144 [details]
Sample project demonstrating the issue
Comment 9 Tom Opgenorth 2017-06-27 18:30:46 UTC
Confirming this bug - attached a sample Xamarin.Android solution which shows the error and another file with the contents of the Application Output pad (with the error).
Comment 10 Tom Opgenorth 2017-06-27 18:31:28 UTC
Created attachment 23145 [details]
Contents of the Application Output pad with the error.

Note You need to log in before you can comment on or make changes to this bug.