Page MenuHomePhabricator

Bug 1507180 - Make copy of list before iterating over it
ClosedPublic

Authored by ytausky on Nov 29 2019, 2:45 PM.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Custom Policy".
phab-bot changed the edit policy from "Custom Policy" to "Custom Policy".
phab-bot added a project: Restricted Project.
phab-bot added subscribers: bc, ytausky, Alex_Gaynor.
sg requested changes to this revision.Nov 29 2019, 3:30 PM
sg added a subscriber: sg.
sg added inline comments.
dom/cache/StreamControl.cpp
60–61

I had a look into the bug today and I am not sure if this change completely addresses the underlying issue. IIUC, the problem is that the StreamControl object is destroyed when the last stream closes. One consequence of that is that mReadStreamList is destroyed as well and the iterator can no longer be used. But isn't the deletion of the object while we are in one of its member functions bad more generally and should be changed?

At least a comment should be added (maybe in a patch to land later) that explains why this is necessary (and maybe that further changes are necessary to address this better). It is a change that could easily be reverted in a later cleanup, since it is not at all obvious.

This revision now requires changes to proceed.Nov 29 2019, 3:30 PM
dom/cache/StreamControl.cpp
60–61

The strange lifecycle management of StreamControl is currently baked into the class such that changing it would be a bigger refactoring. Since I can't reproduce the error and have no test for this, I think a more conservative fix is better for the time being.

dom/cache/StreamControl.cpp
60–61

Ok, I understand that. Please still add a patch to add a comment on the reason for the copy, and maybe add a comment or open another bug to refactor the lifecycle management.

I opened bug 1600570 to address the lifecycle issue, and D55424 to add a comment explaining the necessity of the copy here.

This revision is now accepted and ready to land.Dec 2 2019, 12:45 PM
phab-bot changed the edit policy from "Custom Policy" to "Custom Policy".
phab-bot added a project: Restricted Project.
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".Jun 5 2020, 7:32 AM
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed projects: Restricted Project, Restricted Project, secure-revision.