realm-java: Failure when converting to UTF-8
I get the following crash in production using Realm 2.2.2. The application reads tags from song files and puts them into the realm database. I imagine the string of hex characters are the characters that make up the string. Is that correct? It seems like each character is 20 bits long so I’m not sure what encoding is being used. And what is error code 5?
Fatal Exception: java.lang.IllegalArgumentException: Illegal Argument: Failure when converting to UTF-8; error_code = 5; 0x5468 0x6520 0x5374 0x6561 0x6d20 0x2844 0x6972 0x7479 0x2920 0x284d 0x2900 0x5450 0x3100 0x0020 0x1d00 0x456c 0x6570 0x6861 0x6e74 0x204d 0x616e 0x2066 0x7420 0x4368 0x7269 0x7320 0x4272 0x6f77 0x6e00 0x5452 0x4b00 0x0020 0x0500 0x322f 0x3300 0x434f 0x4d00 0x0020 0x1000 0x656e 0x6769 0x5475 0x6e50 0x4741 0x5000 0x3000 0x0020 0x5445 0x4e00 0x0020 0x0d00 0x6954 0x756e 0x6573 0x2076 0x372e 0x3500 0x434f 0x4d00 0x0020 0x6800 0x656e 0x6769 0x5475 0x6e4e 0x4f52 0x4d00 0x2030 0x3030 0x3030 0x3636 0x4320 0x3030 0x3030 0x3036 0x3544 0x2030 0x3030 0x3033 0x3639 0x4120 0x3030 0x3030 0x3439 0x4541 0x2030 0x3030 0x3133 0x3937 0x3820 0x3030 0x3031 0x4437 0x3644 0x2030 0x3030 0x3039 0x3041 0x4120 0x3030 0x3030 0x3845 0x3335 0x2030 0x3030 0x3137 0x3444 0x4220 0x3030 0x3032 0x3646 0x4336 0x0020 0x434f 0x4d00 0x0020 0x8200 0x656e 0x6769 0x5475 0x6e53 0x4d50 0x4200 0x2030 0x3030 0x3030 0x3030 0x3020 0x3030 0x3030 0x3032 0x3130 0x2030 0x3030 0x3030 0x4139 0x3820 0x3030 0x3030 0x3030 0x3030 0x3030 0x3935 0x3242 0x4438 0x2030 0x3030 0x3030 0x3030 0x3020 0x3030 0x3531 0x3231 0x4343 0x2030 0x3030 0x3030 0x3030 0x3020 0x3030 0x3030 0x3030 0x3030 0x2030 0x3030 0x3030 0x3030 0x3020 0x3030 0x3030 0x3030 0x3030 0x2030 0x3030 0x3030 0x3030 0x3020 0x3030 0x3030 0x3030 0x3030 0x0020 0x434f 0x4d00 0x0020 0x3300 0x656e 0x6769 0x5475 0x6e65 0x735f 0x4344 0x4442 0x5f31 0x0020 0x3139 0x3032 0x3939 0x3033 0x2b35 0x3030 0x3335 0x2b33 0x2b31 0x3530 0x2b31 0x3638 0x3738 0x2b33 0x3335 0x3034 0x0020 0x434f 0x4d00 0x0020 0x1e00 0x656e 0x6769 0x5475 0x6e65 0x735f 0x4344 0x4442 0x5f54 0x7261 0x636b 0x4e75 0x6d62 0x6572 0x0020 0x3200 0x0020 0xfffb 0xb200 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 0x0020 0xfffb 0xb200 0xa680 0x0020 0x3780 0x0020 0x06f0 0x0020 0xde00 0x0020 0x1bc0 in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_UncheckedRow.cpp line 273
at io.realm.internal.UncheckedRow.nativeSetString(UncheckedRow.java)
at io.realm.internal.UncheckedRow.setString(UncheckedRow.java:241)
at io.realm.SongRealmProxy.realmSet$title(SongRealmProxy.java:834)
at io.realm.SongRealmProxy.copy(SongRealmProxy.java:2901)
at io.realm.SongRealmProxy.copyOrUpdate(SongRealmProxy.java:2872)
at io.realm.DefaultRealmModuleMediator.copyOrUpdate(DefaultRealmModuleMediator.java:202)
at io.realm.Realm.copyOrUpdate(Realm.java:1454)
at io.realm.Realm.copyToRealm(Realm.java:883)
at com.kurumilabs.auracle.db.Database.createSongsAndArtists(Database.java:1435)
at com.kurumilabs.auracle.db.Database.<init>(Database.java:112)
at com.kurumilabs.auracle.db.MediaStoreScannerThread$1.handleMessage(MediaStoreScannerThread.java:31)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Version of Realm and tooling
Realm version(s): 2.2.2
Realm sync feature enabled: no
Android Studio version: 2.2.3
Which Android version and device: Pixel XL, 7.1.1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 46 (27 by maintainers)
The exception originates from the conversion of a Java string (16 bits) to a UTF8 string used by Realm Core. Error code 5 indicates that one character isn’t valid (to be more precise, the first half of a surrogate pair is invalid). For example, you have
0x0020 0xDE00
. While0xDE00
might be valid as second surrogate, the first surrogate must be greater than0xD800
(and0x0020
isn’t).Are you using a custom emoji library? Or is your string a
substring()
ortrim()
ed from another string?