realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.46k stars 1.75k forks source link

Fatal Exception converting short string to UTF-16 #4025

Closed pradeep2929 closed 7 years ago

pradeep2929 commented 7 years ago

We are getting following issue on a production app. So there are not much details about it with us, apart from android logs.

Exception io.realm.exceptions.RealmError: Unrecoverable error. Failure when converting short string to UTF-16 error_code = 1; retcode = 0; StringData.size = 32; StringData.data = 9dbca7ae44c14545b7e6088a7e590165; StringData as hex = 0x39 0x64 0x62 0x63 0x61 0x37 0x61 0x65 0x34 0x34 0x63 0x31 0x34 0x35 0x34 0x35 0x62 0x37 0x65 0x36 0x30 0x38 0x38 0x61 0x37 0x65 0x35 0x39 0x30 0x31 0x36 0x35; in_begin = 7e6088a7e590165; in_end = ; out_curr = 0xffa95ffa; out_end = 0xffa96038; in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_UncheckedRow.cpp line 136

io.realm.internal.UncheckedRow.nativeGetString (UncheckedRow.java) io.realm.internal.UncheckedRow.getString (UncheckedRow.java:153) io.realm.RecentChatRealmProxy.realmGet$userId (RecentChatRealmProxy.java:151) com.database.realm.models.RecentChat.getUserId (RecentChat.java:57)

Realm version(s): Latest realm: 2.2.0

Android Studio version: 2.2.2

Which Android version and device:

Samsung - SM-G531F Android OS: 5.1.1

Zhuinden commented 7 years ago

Chat app?

Probably some kind of emoji is acting up...

kneth commented 7 years ago

@pradeep2929 If you have access to the Realm file, we will appreciate if you can send it to help@realm.io. Can you tell us a bit more how you insert data into the Realm file?

macr00 commented 7 years ago

Also experiencing a similar crash when calling Table.getNativeName()

RealmError: Unrecoverable error. Failure when converting short string to UTF-16 error_code = 11; retcode = 0; StringData.size = 22; StringData.data = class_CoordinatesRealm; StringData as hex = 0x63 0x6c 0x61 0x73 0x73 0x5f 0x43 0x6f 0x6f 0x72 0x64 0x69 0x6e 0x61 0x74 0x65 0x73 0x52 0x65 0x61 0x6c 0x6d;

Current Realm version from build file

dependencies { classpath 'com.android.tools.build:gradle:2.2.3' classpath "io.realm:realm-gradle-plugin:2.2.1" }

We will update to 2.3.0 for next release.

kneth commented 7 years ago

@macr00 Thanks for reporting. This is definitely very strange. Your string (class_CoordinatesRealm) consists of one-byte characters only, and all 22 characters have value less than 0x80 (indicating one-byte code point. We have to debug close to see why this happens.

Can you provide a complete stack trace?

pradeep2929 commented 7 years ago

@kneth Thanks for quick reply

i sent you mail on help@realm.io so please check it and give me feedback Thanks

kneth commented 7 years ago

I will try to write a test to check with the string reported by @macr00

kneth commented 7 years ago

I have added native tests (#4100) but I haven't been able to reproduce the crashes yet.

kneth commented 7 years ago

Since the test in #4100 wasn't able to reproduce the errors, I would be happy if you can share a bit of context/code.

bmeike commented 7 years ago

Hey @pradeep2929 Can you share that code with us? If not, I think we'll just close this ticket.

bmeike commented 7 years ago

If there is anything else we can do for you, please don't hesitate to re-open this ticket, or to create a new one.

imrankhanandroid commented 7 years ago

Getting same error :

Caused by io.realm.exceptions.RealmError: Unrecoverable error. Failure when converting short string to UTF-16 error_code = 1; retcode = 0; StringData.size = 10; StringData.data = Ѽez翉24; StringData as hex = 0x02 0xffffff91 0xfffffffc 0x65 0x7a 0xffffffe7 0x3f 0x49 0x32 0x34; in_begin = Ѽez翉24; in_end = ; out_curr = 0x7f7de7eb12; out_end = 0x7f7de7eb70; in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_UncheckedRow.cpp line 138 at io.realm.internal.UncheckedRow.nativeGetString(UncheckedRow.java) at io.realm.internal.UncheckedRow.getString(UncheckedRow.java:166) at io.realm.ContactVoRealmProxy.realmGet$mobile(ContactVoRealmProxy.java:184) at com.citrus.citruspay.database.vo.ContactVo.getMobile(ContactVo.java:62)

StringData.data is Ѽez翉24;

Please help me to avoid this crashing. is there any way to add some validation before calling getMobile from RealmObject subclass. ?

Thanks