{"action":"created","issue":{"url":"https://api.github.com/repos/gdmalet/grtransit/issues/10","labels_url":"https://api.github.com/repos/gdmalet/grtransit/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/gdmalet/grtransit/issues/10/comments","events_url":"https://api.github.com/repos/gdmalet/grtransit/issues/10/events","html_url":"https://github.com/gdmalet/grtransit/issues/10","id":27572181,"number":10,"title":"potential data races in RouteselectActivity.java","user":{"login":"yulin2","id":1483831,"avatar_url":"https://avatars.githubusercontent.com/u/1483831?v=3","gravatar_id":"","url":"https://api.github.com/users/yulin2","html_url":"https://github.com/yulin2","followers_url":"https://api.github.com/users/yulin2/followers","following_url":"https://api.github.com/users/yulin2/following{/other_user}","gists_url":"https://api.github.com/users/yulin2/gists{/gist_id}","starred_url":"https://api.github.com/users/yulin2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yulin2/subscriptions","organizations_url":"https://api.github.com/users/yulin2/orgs","repos_url":"https://api.github.com/users/yulin2/repos","events_url":"https://api.github.com/users/yulin2/events{/privacy}","received_events_url":"https://api.github.com/users/yulin2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-02-14T03:47:43Z","updated_at":"2015-11-09T13:00:28Z","closed_at":null,"body":"Dear developers of grtransit,\r\n\r\nI'm a Ph.D. student and I'm doing research on checking data races for Android apps. I found there is a data race in RouteselectActivity.java:\r\n\r\nAt line 158, the cursor \"mCsr\" is written in the AsyncTask (and this is the only written for \"mCsr\"). However, \"mCsr\" is read by \"onListItemClick\" at line 59 and 60. The order of the written and read is not guaranteed: after the \"onCreate()\" finishes, user may touch the items on the screen (i.e., \"onListItemClick()\" is invoked) and \"mCsr\" is read. But at this time point, the line 158 in AsyncTask may not be executed or not finish yet, because of the non-deterministic of concurrency. If so, there will be a NullPointerException at line 59.\r\n\r\nA quick fix can be add a null checking before line 59:\r\nif(mCsr == null) return;\r\n\r\nA more complex fix would be using wait/notify, or latch.\r\n\r\nWhat do you think?\r\n\r\nThanks,\r\nYu"},"comment":{"url":"https://api.github.com/repos/gdmalet/grtransit/issues/comments/155055878","html_url":"https://github.com/gdmalet/grtransit/issues/10#issuecomment-155055878","issue_url":"https://api.github.com/repos/gdmalet/grtransit/issues/10","id":155055878,"user":{"login":"burcuku","id":5496126,"avatar_url":"https://avatars.githubusercontent.com/u/5496126?v=3","gravatar_id":"","url":"https://api.github.com/users/burcuku","html_url":"https://github.com/burcuku","followers_url":"https://api.github.com/users/burcuku/followers","following_url":"https://api.github.com/users/burcuku/following{/other_user}","gists_url":"https://api.github.com/users/burcuku/gists{/gist_id}","starred_url":"https://api.github.com/users/burcuku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/burcuku/subscriptions","organizations_url":"https://api.github.com/users/burcuku/orgs","repos_url":"https://api.github.com/users/burcuku/repos","events_url":"https://api.github.com/users/burcuku/events{/privacy}","received_events_url":"https://api.github.com/users/burcuku/received_events","type":"User","site_admin":false},"created_at":"2015-11-09T13:00:28Z","updated_at":"2015-11-09T13:00:28Z","body":"Hi,\r\n\r\nI am a PhD student working on concurrency in Android apps. While examining the potential race Yulin has pointed out, I realized that the accesses to mCsr are implicitly ordered and do not result in a real race.\r\n\r\nonListItemClick can be triggered only after the list adapter is set and the items are visible. The list adapter is set in onPostExecute method, after the completion of the task in doInBackground. Hence, mCsr is already set when onListItemClick is executed.\r\n\r\nI would like to get your comments on this issue.\r\n\r\nThanks in advance."}}