{"action":"opened","issue":{"url":"https://api.github.com/repos/bdkjones/VDKQueue/issues/13","labels_url":"https://api.github.com/repos/bdkjones/VDKQueue/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/bdkjones/VDKQueue/issues/13/comments","events_url":"https://api.github.com/repos/bdkjones/VDKQueue/issues/13/events","html_url":"https://github.com/bdkjones/VDKQueue/issues/13","id":70617472,"number":13,"title":"EXC_BAD_ACCESS (SIGSEGV) crash reason","user":{"login":"peternlewis","id":83102,"avatar_url":"https://avatars.githubusercontent.com/u/83102?v=3","gravatar_id":"","url":"https://api.github.com/users/peternlewis","html_url":"https://github.com/peternlewis","followers_url":"https://api.github.com/users/peternlewis/followers","following_url":"https://api.github.com/users/peternlewis/following{/other_user}","gists_url":"https://api.github.com/users/peternlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/peternlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peternlewis/subscriptions","organizations_url":"https://api.github.com/users/peternlewis/orgs","repos_url":"https://api.github.com/users/peternlewis/repos","events_url":"https://api.github.com/users/peternlewis/events{/privacy}","received_events_url":"https://api.github.com/users/peternlewis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-24T07:54:08Z","updated_at":"2015-04-24T07:54:08Z","closed_at":null,"body":"                        //        I was receiving about 3 EXC_BAD_ACCESS (SIGSEGV) crash reports a month that listed the 'path' objc_msgSend\r\n\r\nA sequence which will generate this is:\r\n\r\nVDKQueue deallocs\r\n_keepWatcherThreadRunning = NO\r\n[self removeAllPaths];\r\n\r\nAt that point all entries's are deallocated.\r\n\r\nMeanwhile the thread is stuck in kevent\r\nAn event happens on the file\r\nthe thread reads the event, retrieves the dangling entry pointer from ev.udata\r\ncrash ensues\r\n\r\nMultithreading is hard.\r\n\r\nA bandaid solution would be to add \r\n\r\nif ( !_keepWatcherThreadRunning ) break;\r\n\r\nafter the kevent, that will minimise the period where the dealloc can happen, but it will still be possible, just far less likely.\r\n\r\nReally the events need to be retained by the thread as well and only released when the thread completes, or otherwise the entries need to be validated or looked for some other way that avoids leaving a dangling pointer."}}