{"action":"created","issue":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1180","repository_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios","labels_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1180/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1180/comments","events_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1180/events","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/1180","id":142412972,"number":1180,"title":"Doc can be saved with missing attachment file, leading to errors","user":{"login":"brendand","id":586075,"avatar_url":"https://avatars.githubusercontent.com/u/586075?v=3","gravatar_id":"","url":"https://api.github.com/users/brendand","html_url":"https://github.com/brendand","followers_url":"https://api.github.com/users/brendand/followers","following_url":"https://api.github.com/users/brendand/following{/other_user}","gists_url":"https://api.github.com/users/brendand/gists{/gist_id}","starred_url":"https://api.github.com/users/brendand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendand/subscriptions","organizations_url":"https://api.github.com/users/brendand/orgs","repos_url":"https://api.github.com/users/brendand/repos","events_url":"https://api.github.com/users/brendand/events{/privacy}","received_events_url":"https://api.github.com/users/brendand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-21T17:19:58Z","updated_at":"2016-03-23T02:00:43Z","closed_at":null,"body":"Hi,\r\n\r\nOne of my customers was dragging an email into a File Attachment field in my Mac app and somehow caused a bad attachment to be inserted into the database. So now whenever he launches the app and replication begins, he gets the following crash:\r\n\r\n```\r\n3/21/16 7:07:35.835 AM Tap Forms[1523]: Couldn't get a copy of an HFS Promise from the pasteboard\r\n3/21/16 7:07:36.589 AM Tap Forms[1523]: An uncaught exception was raised\r\n3/21/16 7:07:36.671 AM Tap Forms[1523]: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil\r\n3/21/16 7:07:36.671 AM Tap Forms[1523]: (\r\n\t0   CoreFoundation                      0x00007fff92523ae2 __exceptionPreprocess + 178\r\n\t1   libobjc.A.dylib                     0x00007fff861f0f7e objc_exception_throw + 48\r\n\t2   CoreFoundation                      0x00007fff923c4840 _CFXNotificationGetTaskCenter + 0\r\n\t3   CouchbaseLite                       0x000000010738c245 -[CBLMultiStreamWriter addInput:length:] + 85\r\n\t4   CouchbaseLite                       0x000000010738bbb5 -[CBLMultipartWriter addInput:length:] + 1557\r\n\t5   CouchbaseLite                       0x000000010738c2f1 -[CBLMultiStreamWriter addStream:length:] + 97\r\n\t6   CouchbaseLite                       0x0000000107358300 -[CBLRestPusher multipartWriterForRevision:boundary:] + 2080\r\n\t7   CouchbaseLite                       0x0000000107358587 -[CBLRestPusher uploadMultipartRevision:] + 119\r\n\t8   CouchbaseLite                       0x00000001073561eb __30-[CBLRestPusher processInbox:]_block_invoke + 2299\r\n\t9   CouchbaseLite                       0x000000010736a462 -[CBLRemoteRequest respondWithResult:error:] + 258\r\n\t10  CouchbaseLite                       0x000000010736c9c0 -[CBLRemoteJSONRequest didFinishLoading] + 672\r\n\t11  CouchbaseLite                       0x0000000107416dd6 __57-[CBLRemoteSession URLSession:task:didCompleteWithError:]_block_invoke + 166\r\n\t12  CouchbaseLite                       0x00000001074153d7 __38-[CBLRemoteSession requestForTask:do:]_block_invoke + 183\r\n\t13  CoreFoundation                      0x00007fff924334ac __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12\r\n\t14  CoreFoundation                      0x00007fff92425165 __CFRunLoopDoBlocks + 341\r\n\t15  CoreFoundation                      0x00007fff92424ecb __CFRunLoopRun + 2347\r\n\t16  CoreFoundation                      0x00007fff92424338 CFRunLoopRunSpecific + 296\r\n\t17  Foundation                          0x00007fff95681e61 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270\r\n\t18  CouchbaseLite                       0x00000001073403fa -[CBL_RunLoopServer runServerThread] + 506\r\n\t19  Foundation                          0x00007fff957cdc6f __NSThread__start__ + 1351\r\n\t20  libsystem_pthread.dylib             0x00007fff83508c13 _pthread_body + 131\r\n\t21  libsystem_pthread.dylib             0x00007fff83508b90 _pthread_body + 0\r\n\t22  libsystem_pthread.dylib             0x00007fff83506375 thread_start + 13\r\n)\r\n```\r\n\r\nSome other interesting tidbits from the crash log:\r\n\r\n```\r\nTrace Messages (reverse chronological seconds):\r\n2.551271     CFNetwork                 \t0x00007fff9c99b937 TCP Conn 0x7ffcf63fb5b0 starting SSL negotiation\r\n2.578919     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.579171     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.579479     CFNetwork                 \t0x00007fff9c9995d3 TCP Conn 0x7ffcf63fb5b0 started\r\n2.943779     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.943998     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.944025     CFNetwork                 \t0x00007fff9c9995d3 TCP Conn 0x7ffcf6506c60 started\r\n2.944920     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.944949     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.945454     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.945648     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.945653     CFNetwork                 \t0x000080003bda0e4d Format not found\r\n2.945677     CFNetwork                 \t0x00007fff9c9995d3 TCP Conn 0x7ffcf5cedde0 started\r\n2.946644     libsystem_network.dylib   \t0x000080003e2a7e4d Format not found\r\n```\r\n\r\nNot as interesting, but shows the actual crashed CouchbaseLite thread:\r\n\r\n```\r\nThread 15 Crashed:: CouchbaseLite\r\n0   com.apple.AppKit              \t0x00007fff9359bf86 -[NSApplication _crashOnException:] + 109\r\n1   com.apple.AppKit              \t0x00007fff9359bee0 -[NSApplication reportException:] + 140\r\n2   com.tapzapp.tapforms-mac      \t0x0000000102abb3b9 CLSNSApplicationReportException(objc_object*, objc_selector*, NSException*) + 72\r\n3   com.apple.CoreFoundation      \t0x00007fff9ba38f0b __handleUncaughtException + 731\r\n4   libobjc.A.dylib               \t0x00007fff8f7086a5 _objc_terminate() + 94\r\n5   com.tapzapp.tapforms-mac      \t0x0000000102abb155 CLSTerminateHandler() + 270\r\n6   libc++abi.dylib               \t0x00007fff95c8919e std::__terminate(void (*)()) + 8\r\n7   libc++abi.dylib               \t0x00007fff95c88e27 __cxa_rethrow + 99\r\n8   libobjc.A.dylib               \t0x00007fff8f70641c objc_exception_rethrow + 40\r\n9   com.apple.CoreFoundation      \t0x00007fff9b9393cb CFRunLoopRunSpecific + 443\r\n10  com.apple.Foundation          \t0x00007fff9eb96e61 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270\r\n11  com.couchbase.CouchbaseLite   \t0x00000001030673fa -[CBL_RunLoopServer runServerThread] + 506\r\n12  com.apple.Foundation          \t0x00007fff9ece2c6f __NSThread__start__ + 1351\r\n13  libsystem_pthread.dylib       \t0x00007fff8ca1dc13 _pthread_body + 131\r\n14  libsystem_pthread.dylib       \t0x00007fff8ca1db90 _pthread_start + 168\r\n15  libsystem_pthread.dylib       \t0x00007fff8ca1b375 thread_start + 13\r\n```\r\n\r\n\r\n\r\n--------\r\n* Version:   1.2.1 build (fix/ssl_auth_1168) e0f562761d1fd708b1b6a42b1f8ccae151ca2d6c\r\n* Client OS: OS X 10.11.3\r\n* Server:    IBM Cloudant\r\n"},"comment":{"url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/comments/200127031","html_url":"https://github.com/couchbase/couchbase-lite-ios/issues/1180#issuecomment-200127031","issue_url":"https://api.github.com/repos/couchbase/couchbase-lite-ios/issues/1180","id":200127031,"user":{"login":"brendand","id":586075,"avatar_url":"https://avatars.githubusercontent.com/u/586075?v=3","gravatar_id":"","url":"https://api.github.com/users/brendand","html_url":"https://github.com/brendand","followers_url":"https://api.github.com/users/brendand/followers","following_url":"https://api.github.com/users/brendand/following{/other_user}","gists_url":"https://api.github.com/users/brendand/gists{/gist_id}","starred_url":"https://api.github.com/users/brendand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendand/subscriptions","organizations_url":"https://api.github.com/users/brendand/orgs","repos_url":"https://api.github.com/users/brendand/repos","events_url":"https://api.github.com/users/brendand/events{/privacy}","received_events_url":"https://api.github.com/users/brendand/received_events","type":"User","site_admin":false},"created_at":"2016-03-23T02:00:43Z","updated_at":"2016-03-23T02:00:43Z","body":"Well, NSFileCoordinators are used on iOS also, especially for accessing files on iCloud Drive. So it's not exclusive to Mac programming.\r\n\r\nFor now I've told my beta tester to just delete his database and copy it over to his Mac from the copy he had on the iPhone version of my app.\r\n\r\nBut it would be good if CBL didn't allow saving of empty attachments. Hopefully you can find the cause."}}