Closed
Bug 1316011
Opened 8 years ago
Closed 8 years ago
[findbugs] [VO] Increment of volatile field org.mozilla.gecko.sync.synchronizer.SerialRecordConsumer.counter in org.mozilla.gecko.sync.synchronizer.SerialRecordConsumer.stored()
Categories
(Firefox for Android Graveyard :: General, defect, P3)
Tracking
(firefox53 fixed)
RESOLVED
FIXED
Firefox 53
Tracking | Status | |
---|---|---|
firefox53 | --- | fixed |
People
(Reporter: sebastian, Assigned: sebastian, Mentored)
References
Details
(Whiteboard: [lang=java][good first bug])
Attachments
(2 files, 1 obsolete file)
Increment of volatile field org.mozilla.gecko.sync.synchronizer.SerialRecordConsumer.counter in org.mozilla.gecko.sync.synchronizer.SerialRecordConsumer.stored()
"This code increments a volatile field. Increments of volatile fields aren't atomic. If more than one thread is incrementing the field at the same time, increments could be lost."
Assignee | ||
Comment 1•8 years ago
|
||
To start, set up a build environment - you can see the instructions here:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_for_Android_build
Then, you'll need to upload a patch - see:
http://mozilla-version-control-tools.readthedocs.io/en/latest/mozreview/commits.html
If you need any help, you can reply to this bug, or feel free to message me on IRC - my nick is "sebastian" and you can find me and other helpful folks in #mobile. If you need IRC setup instructions, see https://wiki.mozilla.org/IRC
Comment 2•8 years ago
|
||
Hi
I want to work on fixing this bug.
What do you suggest I do? Should I change the variable counter from Long to AtomicLong?
Hi, I cannot find this file in mozilla-central. I'm looking in mozilla-central/mobile/android/base/java/org/gecko/ but there is no sync directory. Am I looking in the right directory?
Flags: needinfo?(s.kaspari)
Assignee | ||
Comment 4•8 years ago
|
||
(In reply to mddrill from comment #3)
> Hi, I cannot find this file in mozilla-central. I'm looking in
> mozilla-central/mobile/android/base/java/org/gecko/ but there is no sync
> directory. Am I looking in the right directory?
It's here:
https://dxr.mozilla.org/mozilla-central/source/mobile/android/services/src/main/java/org/mozilla/gecko/sync/synchronizer/SerialRecordConsumer.java
Flags: needinfo?(s.kaspari)
Comment 5•8 years ago
|
||
:Sebastian you haven't given me any response yet!!
Assignee | ||
Comment 6•8 years ago
|
||
(In reply to archit garg[:archit] from comment #5)
> :Sebastian you haven't given me any response yet!!
Oh, sorry, I did miss that. Make sure to use the "need more information" flag and I won't be able to miss it. :)
> What do you suggest I do? Should I change the variable counter from Long to
Yeah, this is one option. I see that most access is synchronized. If all access is synchronized then we can just remove the 'volatile' keyword because all threads will see the uncached value anyways.
Comment 7•8 years ago
|
||
Hi sebastian!
I want to work on this bug if nobody is working on it
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 10•8 years ago
|
||
Hi sebastian!
Can you please review my code https://reviewboard-hg.mozilla.org/gecko/rev/73d8cea7d424?
I have removed volatile keyword using AtomicLong and synchronization of counter is done!
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → owaiskazi19
Status: NEW → ASSIGNED
Assignee | ||
Comment 11•8 years ago
|
||
mozreview-review |
Comment on attachment 8818228 [details]
Bug 1316011-Removed use of volatile keyword and thread synchronization is done using AtomicLong Part 2.
https://reviewboard.mozilla.org/r/98374/#review99362
This patch looks like it does not belong here.
If you only want to push a single commit to reviewboard (and assuming you are using mercurial) then you can use "hg push -c CHANGESET".
Attachment #8818228 -
Flags: review?(s.kaspari) → review-
Assignee | ||
Comment 12•8 years ago
|
||
mozreview-review |
Comment on attachment 8818229 [details]
Bug 1316011-Removed use of volatile keyword and thread synchronization is done using AtomicLong
https://reviewboard.mozilla.org/r/98376/#review99364
::: mobile/android/services/src/main/java/org/mozilla/gecko/sync/synchronizer/SerialRecordConsumer.java:86
(Diff revision 1)
> - long counterNow = this.counter;
> - Logger.info(LOG_TAG, "Consumer is done. Processed " + counterNow + ((counterNow == 1) ? " record." : " records."));
> + AtomicLong counterNow = this.counter;
> + Logger.info(LOG_TAG, "Consumer is done. Processed " + counterNow + ((counterNow.get() == 1) ? " record." : " records."));
> delegate.consumerIsDone(stopImmediately);
It looks like the idea here is to cache the current value inside the method so that the value does not change between logging it and deciding between "record" and "records".
Either get the value once and keep the rest of the code:
> long counterNow = counter.get();
Or simplify the log message and just append "record(s)". It's only a log message after all.
Attachment #8818229 -
Flags: review?(s.kaspari)
Assignee | ||
Comment 13•8 years ago
|
||
I pushed the current version of the patch to "try" so that we can see if the tests catch any errors with the new code:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f5fab76461be
Comment 14•8 years ago
|
||
Hi sebastian!
So should i create a new patch or wait for the tests to catch any errors?
Comment 15•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=f5fab76461be&selectedJob=32823613 It is 100% done can you elaborate me with the results please
Assignee | ||
Comment 16•8 years ago
|
||
The failures are related to the other attached patch. Just update the patch (See comment 12) and push it. After that I'll push your updated version to try again.
Comment hidden (mozreview-request) |
Updated•8 years ago
|
Attachment #8818229 -
Attachment is obsolete: true
Assignee | ||
Comment 18•8 years ago
|
||
mozreview-review |
Comment on attachment 8818228 [details]
Bug 1316011-Removed use of volatile keyword and thread synchronization is done using AtomicLong Part 2.
https://reviewboard.mozilla.org/r/98374/#review99454
Attachment #8818228 -
Flags: review?(s.kaspari) → review+
Assignee | ||
Comment 19•8 years ago
|
||
mozreview-review |
Comment on attachment 8818228 [details]
Bug 1316011-Removed use of volatile keyword and thread synchronization is done using AtomicLong Part 2.
https://reviewboard.mozilla.org/r/98374/#review99456
https://treeherder.mozilla.org/#/jobs?repo=try&revision=18108585b3d5
Assignee | ||
Comment 20•8 years ago
|
||
mozreview-review |
Comment on attachment 8818228 [details]
Bug 1316011-Removed use of volatile keyword and thread synchronization is done using AtomicLong Part 2.
https://reviewboard.mozilla.org/r/98374/#review99458
https://treeherder.mozilla.org/#/jobs?repo=try&revision=18108585b3d5
Updated•8 years ago
|
Keywords: checkin-needed
Comment 21•8 years ago
|
||
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/82753b1778fa
Removed use of volatile keyword and thread synchronization is done using AtomicLong Part 2. r=sebastian
Keywords: checkin-needed
Comment 22•8 years ago
|
||
Hi sebastian!
Is the bug complete now?
Comment 23•8 years ago
|
||
With all due respect to everyone involved, this bug should probably be WONTFIXed and the patch backed out. Using an AtomicLong here, for a value that's only present for logging, is overkill. And more thorough analysis would show that there is likely to be no concurrency issue here -- after all, this isn't called SerialRecordConsumer for nothing.
Automated error finding tools should not cause knee-jerk patches to stable code.
Assignee | ||
Comment 24•8 years ago
|
||
Sorry, this is my mistake. I should have analyzed the code more - just because of the synchronization blocks I was assuming this was multi-threaded code (and 'counter' was defined as volatile?). I'll reopen and back out if needed.
Assignee: owaiskazi19 → s.kaspari
Comment 25•8 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox53:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 53
Comment 26•8 years ago
|
||
Is this bug fixed now?
Assignee | ||
Updated•8 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Updated•8 years ago
|
Keywords: leave-open
Assignee | ||
Comment 27•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/c60635c5a851ccd47d0325b0eaab18792ae28964
Backed out changeset 82753b1778fa (bug 1316011)
Comment 28•8 years ago
|
||
backout bugherder |
https://hg.mozilla.org/mozilla-central/rev/c60635c5a851 also backed out from central
Comment hidden (mozreview-request) |
Assignee | ||
Updated•8 years ago
|
Keywords: leave-open
Comment 30•8 years ago
|
||
mozreview-review |
Comment on attachment 8824126 [details]
Bug 1316011 - findbugs: Enable VO_VOLATILE_INCREMENT check and ignore false positive in SerialRecordConsumer.
https://reviewboard.mozilla.org/r/102676/#review104110
Attachment #8824126 -
Flags: review?(walkingice0204) → review+
Comment 31•8 years ago
|
||
Pushed by s.kaspari@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/482d24b7c611
findbugs: Enable VO_VOLATILE_INCREMENT check and ignore false positive in SerialRecordConsumer. r=walkingice
Comment 32•8 years ago
|
||
bugherder |
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•