{"action":"opened","issue":{"url":"https://api.github.com/repos/realm/realm-cocoa/issues/5904","repository_url":"https://api.github.com/repos/realm/realm-cocoa","labels_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5904/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5904/comments","events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/5904/events","html_url":"https://github.com/realm/realm-cocoa/issues/5904","id":356439252,"node_id":"MDU6SXNzdWUzNTY0MzkyNTI=","number":5904,"title":"Shared container file deadlock crash","user":{"login":"jongarate","id":9286257,"node_id":"MDQ6VXNlcjkyODYyNTc=","avatar_url":"https://avatars2.githubusercontent.com/u/9286257?v=4","gravatar_id":"","url":"https://api.github.com/users/jongarate","html_url":"https://github.com/jongarate","followers_url":"https://api.github.com/users/jongarate/followers","following_url":"https://api.github.com/users/jongarate/following{/other_user}","gists_url":"https://api.github.com/users/jongarate/gists{/gist_id}","starred_url":"https://api.github.com/users/jongarate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jongarate/subscriptions","organizations_url":"https://api.github.com/users/jongarate/orgs","repos_url":"https://api.github.com/users/jongarate/repos","events_url":"https://api.github.com/users/jongarate/events{/privacy}","received_events_url":"https://api.github.com/users/jongarate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-03T10:05:14Z","updated_at":"2018-09-03T10:05:14Z","closed_at":null,"author_association":"NONE","body":"## Goals\r\nI'm using RealmCocoa as backend datastore for an app that consists of both a regular iOS app and a today extension (widget). Both components share the same Realm files through App Groups ([as already suggested](https://github.com/realm/realm-cocoa/issues/4899#issuecomment-297121059)) on a shared container and both of them perform network requests to keep data as updated as possible. The issue I'm facing here is that since the widget exists within such a constrained and partially system-controlled context, the extension gets arbitrarily suspended (as it should). When this happens, sometimes resources are closed in the middle of a syncing process (or at least this is my initial hypothesis) and file locks don't have enough time to get properly released.\r\n\r\nIs there any mechanism available to avoid Realm retaining file locks on forced suspension?\r\n\r\nNeedless to say all transactions are wrapped around a try-catch closure so that they get rolled back in case of any failure, but this doesn't seem to help.\r\n\r\n## Expected Results\r\nAll attained file locks are automatically released whenever the extension goes to suspension.\r\n\r\n## Actual Results\r\nThe extension crashes with code \"0xdead10cc\", see [_Other Exception Types_](https://developer.apple.com/library/archive/technotes/tn2151/_index.html#//apple_ref/doc/uid/DTS40008184-CH1-EXCEPTION_INFO). Symbolicated crash log excerpt:\r\n\r\n```\r\nException Type:  EXC_CRASH (SIGKILL)\r\nException Codes: 0x0000000000000000, 0x0000000000000000\r\nException Note:  EXC_CORPSE_NOTIFY\r\nTermination Reason: Namespace ASSERTIOND, Code 0xdead10cc\r\nTriggered by Thread:  0\r\n\r\nThread 0 name:\r\nThread 0 Crashed:\r\n0   libsystem_kernel.dylib        \t0x000000018118fde8 mach_msg_trap + 8\r\n1   libsystem_kernel.dylib        \t0x000000018118fc60 mach_msg + 72 (mach_msg.c:103)\r\n2   CoreFoundation                \t0x00000001816d2e40 __CFRunLoopServiceMachPort + 196 (CFRunLoop.c:2613)\r\n3   CoreFoundation                \t0x00000001816d0908 __CFRunLoopRun + 1568 (CFRunLoop.c:2969)\r\n4   CoreFoundation                \t0x00000001815f0da8 CFRunLoopRunSpecific + 552 (CFRunLoop.c:3245)\r\n5   GraphicsServices              \t0x00000001835d6020 GSEventRunModal + 100 (GSEvent.c:2245)\r\n6   UIKit                         \t0x000000018b610758 UIApplicationMain + 236 (UIApplication.m:3965)\r\n7   libxpc.dylib                  \t0x0000000181399a94 _xpc_objc_main + 556 (main.m:124)\r\n8   libxpc.dylib                  \t0x000000018139bb40 xpc_main + 180 (init.c:1476)\r\n9   Foundation                    \t0x0000000182295fd4 -[NSXPCListener resume] + 180 (NSXPCListener.m:253)\r\n10  PlugInKit                     \t0x0000000186da6ec4 -[PKService run] + 712 (PKService.m:105)\r\n11  PlugInKit                     \t0x0000000186da6ab4 +[PKService main] + 56 (PKService.m:39)\r\n12  PlugInKit                     \t0x0000000186da6ee8 +[PKService _defaultRun:arguments:] + 20 (PKService.m:116)\r\n13  Foundation                    \t0x000000018227ca98 NSExtensionMain + 64 (NSExtensionMain.m:23)\r\n14  libdyld.dylib                 \t0x0000000181081fc0 start + 4\r\n```\r\n\r\n## Steps to Reproduce\r\n<!--- What are steps we can follow to reproduce this issue? -->\r\nCan't really point out. We cannot reproduce the issue because we can't emulate iOS's behavior of suspending a running widget.\r\n\r\n## Version of Realm and Tooling\r\n\r\n```\r\nProductName:\tMac OS X\r\nProductVersion:\t10.13.6\r\nBuildVersion:\t17G65\r\n\r\n/Applications/Xcode.app/Contents/Developer\r\nXcode 9.4.1\r\nBuild version 9F2000\r\n\r\n/Users/foo/.rvm/gems/ruby-2.4.1/bin/pod\r\n1.5.3\r\nRealm (2.6.2)\r\nRealm (= 2.6.2)\r\n\r\n/bin/bash\r\nGNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)\r\n\r\n/usr/local/bin/carthage\r\n0.30.1\r\n(not in use here)\r\n\r\n/usr/bin/git\r\ngit version 2.15.2 (Apple Git-101.1)\r\n```\r\n"}}
{"actor":{"display_login":"jongarate"}}