{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/5808","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/5808/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/5808/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/5808/events","html_url":"https://github.com/realm/realm-java/issues/5808","id":302833855,"number":5808,"title":"Native Crash on RealmObject Update","user":{"login":"bmadaras","id":602063,"avatar_url":"https://avatars0.githubusercontent.com/u/602063?v=4","gravatar_id":"","url":"https://api.github.com/users/bmadaras","html_url":"https://github.com/bmadaras","followers_url":"https://api.github.com/users/bmadaras/followers","following_url":"https://api.github.com/users/bmadaras/following{/other_user}","gists_url":"https://api.github.com/users/bmadaras/gists{/gist_id}","starred_url":"https://api.github.com/users/bmadaras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmadaras/subscriptions","organizations_url":"https://api.github.com/users/bmadaras/orgs","repos_url":"https://api.github.com/users/bmadaras/repos","events_url":"https://api.github.com/users/bmadaras/events{/privacy}","received_events_url":"https://api.github.com/users/bmadaras/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-06T19:28:01Z","updated_at":"2018-03-07T16:10:53Z","closed_at":null,"author_association":"NONE","body":"#### Goal\r\nUpdate a saved object with a new version from service\r\n\r\n#### Expected Results\r\nUpdate the current object\r\n\r\n#### Actual Results\r\n03-06 18:59:29.626 10104-10104/com.armssoftware.android A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 10104 (oftware.android)\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.0.0/OSR1.170901.056/4497355:userdebug/dev-keys'\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: Revision: '0'\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: ABI: 'x86'\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: pid: 10104, tid: 10104, name: oftware.android  >>> com.armssoftware.android <<<\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG: Cause: null pointer dereference\r\n03-06 18:59:29.784 10416-10416/? A/DEBUG:     eax 00000000  ebx 922f5de4  ecx bfcef948  edx 00000001\r\n03-06 18:59:29.785 10416-10416/? A/DEBUG:     esi 00000000  edi 00000000\r\n03-06 18:59:29.785 10416-10416/? A/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b\r\n03-06 18:59:29.785 10416-10416/? A/DEBUG:     eip 920a4c19  ebp 912b8c0c  esp bfcef900  flags 00010297\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG: backtrace:\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #00 pc 000e4c19  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #01 pc 000e4eb7  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #02 pc 001114a7  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #03 pc 00111a47  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #04 pc 000f69d8  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #05 pc 000d6658  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #06 pc 00112d49  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #07 pc 00112fd6  /data/app/com.armssoftware.android-eOMGXnD93VYA658DwCiaqg==/lib/x86/librealm-jni.so\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #08 pc 00014a37  /system/lib/libutils.so (_ZN7android20SimpleLooperCallback11handleEventEiiPv+39)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #09 pc 0001586c  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+988)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #10 pc 00015406  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+118)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #11 pc 000e4cbb  /system/lib/libandroid_runtime.so (_ZN7androidL38android_os_MessageQueue_nativePollOnceEP7_JNIEnvP8_jobjectxi+59)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #12 pc 007b4198  /system/framework/x86/boot-framework.oat (offset 0x5e6000) (android.app.NativeActivity.onWindowFocusChangedNative [DEDUPED]+136)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #13 pc 000756a0  /dev/ashmem/dalvik-jit-code-cache (deleted)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #14 pc 4a292753  <unknown>\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #15 pc 0d3fffff  /dev/ashmem/dalvik-main space (region space) (deleted)\r\n03-06 18:59:30.027 10416-10416/? A/DEBUG:     #16 pc 00d25f9a  /system/framework/x86/boot-framework.vdex\r\n\r\n#### Steps & Code to Reproduce\r\nCurrently in process of upgrading from version 3.3.2 to 4.3.4\r\n\r\nThis pattern is in place for many other models and all seem to work without issue so my assumption is that there is something wrong with the model.\r\n\r\nInsert the model with some of the properties missing, summary level, then come back and get the full detail of the model and try to update.\r\n\r\nCleared the database and started from scratch.\r\nModified model to remove list and index.\r\nTried beginning and then committing a transaction on the realm instance as am currently executing a Realm.Transaction synchronously.\r\n\r\n#### Code Sample\r\n\r\n```java\r\n//This is being executed on a background thread\r\nnew Runnable() {\r\n            @Override\r\n            public void run() {\r\nfinal Response<Group> response =\r\n                            api.getGroupDetail(sportId, groupId).execute();\r\n\r\n                    Realm realm = SportRealmConfiguration.getSportRealmInstance();\r\n                    if (response.isSuccessful()) {\r\n                        final RosterGroup updatedGroup = response.body();\r\n                            realm.executeTransaction(new Realm.Transaction() {\r\n                                @Override\r\n                                public void execute(final Realm realm) {\r\n                                    realm.insertOrUpdate(updatedGroup);\r\n                                }\r\n                            });\r\n\r\n                    }\r\n}\r\n        }\r\n\r\n//Model\r\npublic class Group extends RealmObject {\r\n\r\n    public static final String PK = \"groupId\";\r\n    public static final String FIELD_SPORT = \"sportId\";\r\n    public static final String FIELD_TYPE = \"type\";\r\n    public static final String FIELD_NAME = \"name\";\r\n\r\n    public static final String TYPE_MANUAL = \"M\";\r\n    public static final String TYPE_SMART = \"S\";\r\n\r\n    @PrimaryKey\r\n    private long groupId;\r\n    private String name;\r\n    private String type;\r\n    private Integer count;\r\n    @Index\r\n    private long sportId;\r\n    private RealmList<RealmLong> contactIds = new RealmList<>();\r\n\r\n    public long getGroupId() {\r\n        return groupId;\r\n    }\r\n\r\n    public void setGroupId(final long groupId) {\r\n        this.groupId = groupId;\r\n    }\r\n\r\n    public String getName() {\r\n        return name;\r\n    }\r\n\r\n    public void setName(final String name) {\r\n        this.name = name;\r\n    }\r\n\r\n    public String getType() {\r\n        return type;\r\n    }\r\n\r\n    public void setType(final String type) {\r\n        this.type = type;\r\n    }\r\n\r\n    public Integer getCount() {\r\n        return count;\r\n    }\r\n\r\n    public void setCount(final Integer count) {\r\n        this.count = count;\r\n    }\r\n\r\n    public long getSportId() {\r\n        return sportId;\r\n    }\r\n\r\n    public void setSportId(final long sportId) {\r\n        this.sportId = sportId;\r\n    }\r\n\r\n    public RealmList<RealmLong> getContactIds() {\r\n        return contactIds;\r\n    }\r\n\r\n    public void setContactIds(final RealmList<RealmLong> contactIds) {\r\n        this.contactIds = contactIds;\r\n    }\r\n\r\n    @Override\r\n    public String toString() {\r\n        return \"Group{\" +\r\n                \"groupId=\" + groupId +\r\n                \", name='\" + name + '\\'' +\r\n                \", type='\" + type + '\\'' +\r\n                \", count=\" + count +\r\n                \", sportId=\" + sportId +\r\n                \", contactIds=\" + contactIds +\r\n                '}';\r\n    }\r\n}\r\n\r\npublic class RealmLong extends RealmObject {\r\n    private long value;\r\n\r\n    public RealmLong() {\r\n    }\r\n\r\n    public RealmLong(final long value) {\r\n        this.value = value;\r\n    }\r\n\r\n    public long getValue() {\r\n        return value;\r\n    }\r\n\r\n    public void setValue(long value) {\r\n        this.value = value;\r\n    }\r\n\r\n    @Override\r\n    public boolean equals(final Object o) {\r\n        if (this == o) return true;\r\n        if (o == null || getClass() != o.getClass()) return false;\r\n\r\n        RealmLong realmLong = (RealmLong) o;\r\n\r\n        return getValue() == realmLong.getValue();\r\n\r\n    }\r\n\r\n    @Override\r\n    public int hashCode() {\r\n        return (int) (getValue() ^ (getValue() >>> 32));\r\n    }\r\n}\r\n```\r\n\r\n#### Version of Realm and tooling\r\nRealm version(s): 4.3.4\r\n\r\nRealm sync feature enabled: no\r\n\r\nAndroid Studio version: 3.0.1\r\n\r\nWhich Android version and device: on a few different devices, currently troubleshooting on API 26 emulator\r\n"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/371190029","html_url":"https://github.com/realm/realm-java/issues/5808#issuecomment-371190029","issue_url":"https://api.github.com/repos/realm/realm-java/issues/5808","id":371190029,"user":{"login":"bmadaras","id":602063,"avatar_url":"https://avatars0.githubusercontent.com/u/602063?v=4","gravatar_id":"","url":"https://api.github.com/users/bmadaras","html_url":"https://github.com/bmadaras","followers_url":"https://api.github.com/users/bmadaras/followers","following_url":"https://api.github.com/users/bmadaras/following{/other_user}","gists_url":"https://api.github.com/users/bmadaras/gists{/gist_id}","starred_url":"https://api.github.com/users/bmadaras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmadaras/subscriptions","organizations_url":"https://api.github.com/users/bmadaras/orgs","repos_url":"https://api.github.com/users/bmadaras/repos","events_url":"https://api.github.com/users/bmadaras/events{/privacy}","received_events_url":"https://api.github.com/users/bmadaras/received_events","type":"User","site_admin":false},"created_at":"2018-03-07T16:10:53Z","updated_at":"2018-03-07T16:10:53Z","author_association":"NONE","body":"Yes the removal of change listeners is in the onDestroy callback and it is still happening.\r\n\r\nI was moving around the change listener code and oddly enough what I have found is that if I add the change listener in the onCreate it will crash but if it is added in the onStart method it will not.\r\n\r\nThis does not make much sense to me."}}
{"actor":{"display_login":"bmadaras"}}