Closed Bug 1645339 Opened 5 years ago Closed 5 years ago

Use range-based for with nsTObserverArray where easily possible

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: sg, Assigned: sg)

References

Details

Attachments

(19 files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
No description provided.
Assignee: nobody → sgiesecke
Status: NEW → ASSIGNED
Blocks: 1645382

The bug could explain why? :)

Keywords: leave-open
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5329613a793b Use range-based for with nsTObserverArray in xpcom. r=froydnj
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e6239a2ea63d Use range-based for with nsTObserverArray in docshell. r=nika https://hg.mozilla.org/integration/autoland/rev/9e423eab275c Use range-based for with nsTObserverArray in accessible. r=MarcoZ https://hg.mozilla.org/integration/autoland/rev/ea0b74e44d75 Use range-based for with nsTObserverArray in dom/abort. r=smaug https://hg.mozilla.org/integration/autoland/rev/c8ee4717dac6 Use range-based for with nsTObserverArray in dom/audiochannel. r=baku https://hg.mozilla.org/integration/autoland/rev/91138138812e Use range-based for with nsTObserverArray in layout/generic. r=tnikkel https://hg.mozilla.org/integration/autoland/rev/490fa07526ce Use range-based for with nsTObserverArray in dom/events. r=smaug https://hg.mozilla.org/integration/autoland/rev/346a1bc55d57 Use range-based for with nsTObserverArray in dom/performance. r=baku https://hg.mozilla.org/integration/autoland/rev/d091f09fb8ad Use range-based for with nsTObserverArray in dom/reporting. r=smaug https://hg.mozilla.org/integration/autoland/rev/a3218470c558 Use range-based for with nsTObserverArray in mobile/android. r=geckoview-reviewers,agi https://hg.mozilla.org/integration/autoland/rev/756fe40189b7 Use range-based for with nsTObserverArray in xpfe. r=smaug
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/73823aa5538b Use range-based for with nsTObserverArray in layout/base. r=tnikkel https://hg.mozilla.org/integration/autoland/rev/e86ae0d0b516 Use range-based for with nsTObserverArray in dom/cache. r=dom-workers-and-storage-reviewers,edenchuang https://hg.mozilla.org/integration/autoland/rev/448405bd15a2 Use range-based for with nsTObserverArray in dom/serviceworkers. r=dom-workers-and-storage-reviewers,edenchuang https://hg.mozilla.org/integration/autoland/rev/780ae7d7aba4 Use range-based for with nsTObserverArray in dom/workers. r=dom-workers-and-storage-reviewers,edenchuang https://hg.mozilla.org/integration/autoland/rev/0d6545fa7762 Use range-based for with nsTObserverArray in dom/storage. r=dom-workers-and-storage-reviewers,edenchuang

(In reply to Olli Pettay [:smaug] from comment #20)

The bug could explain why? :)

Did this get answered somewhere? (I should have needinfo'ed previously when deciding to block on this, apologies.)

Flags: needinfo?(sgiesecke)

It wasn't answered and I commented my worry about this in
https://phabricator.services.mozilla.com/D79495
(but r+'ed anyhow)

smaug, while I somehow missed your question saw your comment on the patch, and I planned on responding to that, I somehow missed your comment here.

I am not sure: From my point of view, it is desirable to reduce custom (for/while) loops and in particular use range-based for because it is more expressive. While a custom (for/while) loop has several places where the iteration can be controlled, the range-based for syntax restricts this to the range clause. It is clear that the loop body has only access to the current item, and cannot modify the iterator. (I am not sure if I can add anything to the general reasons why range-based was introduced to the C++ standard).

I am not completely sure how this relates to your comment on the patch, and I would like to better understand that. In what sense does it hide how the iteration happens? Can you point me to some example where using range-based for caused a security issue?

Flags: needinfo?(sgiesecke)

I don't expect there to be security issues when dealing with nsTObserverArray, since that is designed to deal with mutations. But we've had
several security critical issues when some other data structure has been iterated using ranged-for and while iterating, something has modified the data structure. The issue there is that range-for hides what actually happens underneath, and in some sense it is too
handy way to iterate, so the patch author, nor the reviewer might not think about what happens if the data structure is modified.
(nsTArray should just crash safely these days, but even a safe crash is rather annoying for the user.)

Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6a67e37ca0cc Use range-based for with nsTObserverArray in dom/debugger. r=loganfsmyth https://hg.mozilla.org/integration/autoland/rev/eff64e6c4ac9 Use range-based for with nsTObserverArray in layout/style. r=heycam
Keywords: leave-open
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8dd1af6f4953 Use range-based for with nsTObserverArray in dom/base. r=asuth,dom-workers-and-storage-reviewers

(In reply to Narcis Beleuzu [:NarcisB] from comment #34)

Backed out for bustages on nsGlobalWindowInner.cpp

Backout link: https://hg.mozilla.org/integration/autoland/rev/324d5257f6f7cd287565dd822b13d3b5acc0ef14
Log link: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=307515741&repo=autoland&lineNumber=25276

Sorry for that, I resolved the bustage and updated the patch, and will re-land it.

Flags: needinfo?(sgiesecke)
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6e112475566e Use range-based for with nsTObserverArray in dom/base. r=asuth,dom-workers-and-storage-reviewers
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: