Closed Bug 722575 Opened 8 years ago Closed 8 years ago

SerialRecordConsumer.java consumerIsDone() is not threadsafe

Categories

(Firefox for Android :: Android Sync, defect, P3)

ARM
Android
defect

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: dchanm+bugzilla, Assigned: nalexander)

References

Details

(Whiteboard: [qa-])

consumerIsDone() reads the counter variable in a non-threadsafe manner. This isn't a huge deal since the value is only used for logging purposes. 

Threads (T1, T2)
T1 calls run()
T1 obtains lock for monitor
T1 calls consumerIsDone()
T1 executes info() and checks for value of counter (let's say 0)
T1 is context switched out before ?: executes
T2 calls storeSerially()
T2 obtains lock for storeSerializer
T2 increments counter
T2 is context switched out
T1 finishes info call and logs
"Consumer is done. Processed 0 records."
since counter == 1 is now true

[1] - https://github.com/mozilla-services/android-sync/blob/develop/src/main/java/org/mozilla/gecko/sync/synchronizer/SerialRecordConsumer.java#L133
(In reply to David Chan [:dchan] from comment #0)
> This isn't a huge deal since the value is only used for logging purposes. 

Yup, that's why I left it for now :D  Thanks for filing, though!
Priority: -- → P3
Blocks: 723230
https://hg.mozilla.org/services/services-central/rev/e24e2c2da258
Assignee: nobody → nalexander
Status: NEW → ASSIGNED
Whiteboard: [fixed in services][qa-]
https://hg.mozilla.org/mozilla-central/rev/16bf8c62011d
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
https://hg.mozilla.org/mozilla-central/rev/e24e2c2da258
Whiteboard: [fixed in services][qa-] → [qa-]
Product: Mozilla Services → Android Background Services
Product: Android Background Services → Firefox for Android
You need to log in before you can comment on or make changes to this bug.