bugsnag/bugsnag-android

BugSnag.isStarted() implementation isn't thread safe

jgreen210 opened this issue · 2 comments

Describe the bug

The BugSnag.isStarted() implementation isn't thread safe: #1640 (comment)

See #883 too.

Hey @jgreen210,

Thanks for the suggestion.

A couple of points regarding the current implementation:

If isStarted returns true then getClient will not throw an exception, which is expected.
It is allowed to return false while start is in-flight.

Adding the lock would require isStarted to wait while start completes before returning, which is not always desirable. So is not something we would want to do.

Adding the lock would require isStarted to wait while start completes before returning, which is not always desirable. So is not something we would want to do.

OK, but there is still a bug here. If you don't want to obtain the lock in isStarted, then could use an AtomicBoolean to ensure there's a memory barrier. It might also be possible to fix it some other way when fix #1731 (comment)