Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for null as primary key to avoid: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" #914

Closed
ghost opened this issue Feb 27, 2015 · 4 comments
Assignees

Comments

@ghost
Copy link

ghost commented Feb 27, 2015

Found this error while normal development. I haven't been able to reproduce it with what I think is the same data/situation.

version: 0.79.1
device: NEXUS 6 - Android 5.0.1

JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring
in call to GetStringChars
from long io.realm.internal.Table.nativeFindFirstString(long, long, java.lang.String)
"IntentService[SyncService]" prio=5 tid=29 Runnable
| group="main" sCount=0 dsCount=0 obj=0x12fd89e0 self=0xac489400
| sysTid=22693 nice=0 cgrp=apps sched=0/0 handle=0xaf25e600
| state=R schedstat=( 249521400 80332037 348 ) utm=23 stm=1 core=1 HZ=100
| stack=0x9f85e000-0x9f860000 stackSize=1036KB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 00004c58 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext_)+23)
native: #1 pc 000034c1 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext_)+8)
native: #2 pc 002526ad /system/lib/libart.so (art::DumpNativeStack(std::_1::basic_ostream<char, std::1::char_traits >&, int, char const,
native: #3 pc 0023618b /system/lib/libart.so (art::Thread::Dump(std::1::basic_ostream<char, std::1::char_traits >&) const+162)
native: #4 pc 000b1215 /system/lib/libart.so (art::JniAbort(char const
, char const
)+620)
native: #5 pc 000b1945 /system/lib/libart.so (art::JniAbortF(char const
, char const
, ...)+68)
native: #6 pc 000b33df /system/lib/libart.so (art::ScopedCheck::CheckInstance(art::ScopedCheck::InstanceKind, jobject)+374)
native: #7 pc 000b3e43 /system/lib/libart.so (art::ScopedCheck::Check(bool, char const
, ...) (.constprop.128)+762)
native: #8 pc 000bd59b /system/lib/libart.so (art::CheckJNI::GetStringChars(JNIEnv, jstring, unsigned char
)+66)
native: #9 pc 000835d7 /data/app/de.komoot.android-1/lib/arm/libtightdb-jni.so (???)
native: #10 pc 00062d41 /data/app/de.komoot.android-1/lib/arm/libtightdb-jni.so (Java_io_realm_internal_Table_nativeFindFirstString+36)
native: #11 pc 0068d5c1 /data/dalvik-cache/arm/data@app@de.komoot.android-1@base.apk@classes.dex (
at io.realm.internal.Table.nativeFindFirstString(Native method)
at io.realm.internal.Table.findFirstString(Table.java:1401)
at io.realm.RealmRouteRealmProxy.copyOrUpdate(RealmRouteRealmProxy.java:704)
at java.lang.reflect.Method.invoke!(Native method)
at java.lang.reflect.Method.invoke(Method.java:372)
at io.realm.Realm.copyOrUpdate(Realm.java:1615)
at io.realm.Realm.copyToRealmOrUpdate(Realm.java:1207)
...

@kneth
Copy link
Contributor

kneth commented Mar 2, 2015

I can see that you have a data model which is using primary keys, and you have created an object and it going to copy it to your Realm. From the stack trace, I think that the field which is your primary key, is set to null. It is not supported to use null as value for a primary key, and we don't check it (we probably should - just to give you a better error message).

@intrications
Copy link

@kneth That was my problem. I had a primary key and I was accidentally trying to save an object created with the no-operator constructor.

A better error message would definitely have helped.

@bmunkholm bmunkholm changed the title crash found: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" Check null is not used a value for primary key field to avoid: crash found: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" Mar 2, 2015
@bmunkholm bmunkholm changed the title Check null is not used a value for primary key field to avoid: crash found: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" crash found: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" Mar 2, 2015
@bmunkholm bmunkholm added the P1 label Mar 2, 2015
@bmunkholm bmunkholm changed the title crash found: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" Add check for null as primary key to avoid: "JNI DETECTED ERROR IN APPLICATION: GetStringChars received null jstring" Mar 3, 2015
@VishwanathPatil
Copy link

I have similar problem , when jstring is passed as not being null , still this error shows up .
if(Data) char_Data = (*env)->GetStringUTFChars (env, Data, NULL);

@kneth
Copy link
Contributor

kneth commented Mar 13, 2015

@VishwanathPatil Does the error message vanish if you don't use a primary key?

@kneth kneth self-assigned this Jun 8, 2015
@kneth kneth removed the P1 label Jun 9, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants