New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

potential races in MessageActivity.java and MessageViewFragment.java #60

Closed
yulin2 opened this Issue Feb 13, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@yulin2

yulin2 commented Feb 13, 2014

Dear developers of irccloud,

I'm a Ph.D. student and I'm doing research on checking data races for
Android apps. I found potential races in MessageActivity.java and
MessageViewFragment.java:

In MessageActivity.java at line 649, "messageTxt" is used in an
AsyncTask. Android document suggests that we shouldn't access GUI
wedgits out of UI thread. Is this a potential race with other access
to "messageTxt" in UI thread (for example, user can change the text
of "messageTxt" concurrently, or "messageTxt.setText" is invoked at
line 544 and so on). Why not move "messageTxt.getText().toString()" at
line 649 to "preExecute" and pass the String to "doInBackground"?

In MessageViewFragment.java at line 1305,
"EventsDataSource.getInstance()" is invoked in an AsyncTask and it
returns a singleton EventsDataSource object. However, this method is
also invoked many times by UI thread, e.g., line 213, 395 and so
on. Since this method is not synchronized, it is possible that the
EventsDataSource object is created multiple times (thus, not singleton anymore)
when invoked concurrently. So we can make this method synchronized.

Also, at the same line 1305, "buffer.bid" is read in AsyncTask, but
"buffer" is also initialized at line 806. I'm not sure if these two
statements may happen in parallel. If so, this is also a data race
that may lead to bugs.

What's your opinion?

Thanks,
Yu

@c99koder c99koder closed this in c81f337 Feb 17, 2014

@c99koder

This comment has been minimized.

Show comment
Hide comment
@c99koder

c99koder Feb 17, 2014

Member

Thanks for letting us know about these issues!

Member

c99koder commented Feb 17, 2014

Thanks for letting us know about these issues!

@yulin2

This comment has been minimized.

Show comment
Hide comment
@yulin2

yulin2 Feb 17, 2014

You're welcome:) I'm glad to see our report is useful.

yulin2 commented Feb 17, 2014

You're welcome:) I'm glad to see our report is useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment