Getting a weird behavior when saving a string
java.lang.RuntimeException: Unspecified exception. Failure when converting short string to UTF-16 0x20 0xae 0x00 0x00 0x90 0xae 0x00 0x00 0x98 0x54 0x01 in io_realm_internal_Row.cpp line 126
at io.realm.internal.Row.nativeGetString(Native Method)
at io.realm.internal.Row.getString(Row.java:126)
at io.realm.MessageModelRealmProxy.getMessage(MessageModelRealmProxy.java:108)
Hi @ImGauravC Thank you very much. Can you provide some more information. Do you know what string you expected to get when calling getMessage()?
Can it be replicated? Can you send the realm file to [email protected]?
@cmelchior : getMessage() should be a normal text message that includes emoji characters. @bmunkholm : Sure. I'll send the realm file the next time I see this.
@ImGauravC Can you send us your realm file? It might give us a hint where the problem is.
Hi all, I got similar exception after upgrading to version 0.77. This happens when scrolling on a listview but I have a background thread running so I'm not sure where the exception came from.
Edit: this exist on version 76 too. I think I did something wrong but still don't know the cause.
java.lang.RuntimeException: Unspecified exception. Failure when computing UTF-16 size error_code = 1; StringData.size = 23139; StringData.data = 2015-04-14 21:00; StringData as hex = 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x32 0x31 0x3a 0x30 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x31 0x39 0x3a 0x35 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x32 0x32 0x3a 0x31 0x35 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x30 0x36 0x3a 0x35 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x30 0x38 0x3a 0x34 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x31 0x30 0x3a 0x30 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x31 0x32 0x3a 0x32 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x32 0x30 0x3a 0x31 0x30 0x00 0x32 0x30 0x31 0x35 0x2d 0x30 0x34 0x2d 0x31 0x34 0x20 0x32 0x33 0x3a 0x35 0x30 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x02 0x68 0x27 0xa0 0x27 0x77 0x77 0x77 0x97 0x00 0x01 0x10 0x00 0x0c 0x00 0x00 0x15 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x4e 0x2f 0x41 0x00 0x00 0x00 0x00 0x04 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x41 0x33 0x32 0x30 0x00 0x00 0x00 0x03 0x00 0x00 0x58 0x00 0x04 0x00 0x00 0x15 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x1c 0x00 0x00 0x00 0x00 0x00 0x58 0x00 0x04 0x00 0x00 0x15 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x59 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x44 0x00 0x00 0x15 0x01 0x03 0x05 0x07 0x09 0x0b 0x0d 0x0f 0x11 0x13 0x15 0x17 0x19 0x1b 0x1d 0x1f 0x21 0x23 0x25 0x27 0x29 0x1a 0x48 0x1a 0x00 0x00 0x80 0x00 0x40 0x00 0x00 0x15 0x00 0x00 0x80 0x00 0x40 0x00 0x00 0x15 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x0c 0x30 0x24 0xe0 0x24 0xf0 0x24 0xf8 0x26 0x08 0x27 0x10 0x29 0x20 0x29 0xd0 0x29 0xf0 0x29 0x10 0x2a 0x30 0x2a 0x38 0x2a 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x02 0x60 0x07 0x40 0x2a 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x40 0x00 0x00 0x00 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x0a 0x90 0x08 0xa0 0x08 0xb0 0x08 0xb8 0x08 0xc0 0x08 0x70 0x2a 0x78 0x2a 0xd8 0x08 0xe0 0x08 0xe8 0x08 0x30 0x2a 0x38 0x2a 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x02 0x80 0x08 0x80 0x2a 0x00 0x00 0x00 0x00 0x00 0x03 0x50 0x00 0x0d 0x00 0x00 0x22 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x78 0x65 0x63 0x75 0x74 0x69 0x76 0x65 0x00 0x00 0x00 0x00 0x00 0x00 0x06 0x45 0x63 0x6f 0x6e 0x6f 0x6d 0x79 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x45 0x78 0x65 0x63 0x75 0x74 0x69 0x76 0x65 0x00 0x00 0x00 0x00 0x00 0x0
Nevermind, I just commented some of my code and the error's gone, so I have to inspect in that area. Loading realm data in adapter is ridiculously fast after I move data preprocessing on background thread :-)
Hey, we are experiencing similar errors on our application. The rate is really low but we cannot identify the problem. Was there any solution to this issue?
We are currently using Realm 0.80.2.
Our error messages look like:
java.lang.RuntimeException: Unspecified exception. Failure when converting short string to UTF-16 error_code = 1; retcode = 0; StringData.size = 3; StringData.data = 螽; StringData as hex = 0xe8 0x9e 0x3d; in_begin = 螽; in_end = ; out_curr = 0xbe8882a0; out_end = 0xbe888300; in io_realm_internal_Row.cpp line 137 at io.realm.internal.Row.nativeGetString(Row.java) at io.realm.internal.Row.getString(Row.java:124)
Thanks
Is the behavior consistent with that particular string?
No we get this error for completely different strings (even pure ascii):
Unspecified exception. Failure when converting short string to UTF-16 error_code = 1; retcode = 0; StringData.size = 36; StringData.data = 3d876a10; StringData as hex = 0x33 0x64 0x38 0x37 0x36 0x61 0x31 0x30 0x00 0x00 0x80 0x00 0x45 0x00 0x00 0x02 0x28 0x01 0xb8 0x01 0x31 0x3a 0x34 0x31 0x00 0x00 0x80 0x00 0x65 0x00 0x00 0x01 0x30 0x09 0xb8 0x01; in_begin = ; in_end = 1:41; out_curr = 0x78bc5a6c; out_end = 0x78bc5ab8; in io_realm_internal_Row.cpp line 137
In this case the string was generated with UUID.randomUUID().toString().
In other cases (like the one posted before) the data is usergenerated or contains json.
Edit: the StringData.data seems to be cut-off as it is too short for a UUID
Thank you! That is a very useful report. Are you able to reproduce it consistently with a particular String?
Sadly not. We only get crash report via our tracking, but are not able to reproduce it locally. We experience the crash mostly on Android 4.4.2 but also on Android 5.x and 4.2.x. and only in low numbers.
And it seems like that users that experience that error, cannot be recovered until the entry is removed (but not sure about it, it's just that the crash to user ration is 4:1)
Maybe this is related to https://github.com/realm/realm-java/issues/982
@cmelchior can't tell because it's a private repository ;)
Yeah, sorry about that. The public error was this one: #982, the root cause for that was also related to Strings not being saved correctly.
Ok, thank you for the update
Something similar in my case:
Caused by: java.lang.RuntimeException: Unspecified exception. Failure when computing UTF-16 size error_code = 5; retcode = 1350; StringData.size = 89831; StringData.data = Sacha; StringData as hex = 0x53 0x61 0x63 0x68 0x61 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0a 0x4a 0x6f 0x72 0x6e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00...(more of this stuff); in_begin = Sacha; in_end = ; out_curr = 0xbebe02d0; out_end = 0xbebe0330; in io_realm_internal_Row.cpp line 137
at io.realm.internal.Row.nativeGetString(Row.java)
at io.realm.internal.Row.getString(Row.java:124)
at io.realm.UserRealmRealmProxy.getToken(UserRealmRealmProxy.java:138)
UPDATE: Stop getting this exception after I spotted and fixed OOM due to many long leaving Realm instances.
@RobertoArtiles Thanks for the report and especially the update. I have had a hypothesis for some time that an OOM might lead to a mild corruption of the Realm file. The mild corruption shows up as an invalid string. Your observation supports my hypothesis.
Said that, an OOM should never lead to corruption of data (Realm or anything else). I will focus my investigate in an OOM sceneria.
@RobertoArtiles Can you tell me a little more about these OOMs? Did you do a try-catch which ignore the OOM before? Or did you actively catch the error and do something?
We also observe some OOM, but we ignore them right now, due to low numbers:
Fatal Exception: java.lang.RuntimeException Unspecified exception. mmap() failed: Out of memory in io_realm_internal_SharedGroup.cpp line 164 raw io.realm.internal.SharedGroup.nativeCommitAndContinueAsRead (SharedGroup.java) io.realm.internal.SharedGroup.commitAndContinueAsRead (SharedGroup.java:103) io.realm.internal.ImplicitTransaction.commitAndContinueAsRead (ImplicitTransaction.java:45) io.realm.Realm.commitTransaction (Realm.java:1465)
I think your apps are running out of a native resource, and mmap() is failing. We shouldn't throw an RuntimeException in that case - an OutOfMemoryError would be better. I understand that OutOfMemoryError would make the app to fail but the Realm file would be left in a consistent state.