Potentially unsafe iteration in SurfaceStack (if used wrong)
Bug #1630801 reported by
Chris Halse Rogers
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mir |
New
|
Medium
|
Unassigned | ||
mir (Ubuntu) |
New
|
Medium
|
Unassigned |
Bug Description
RecursiveReadLocks don't exclude modification by the same thread.
This means that code like:
void ms::SurfaceStac
{
RecursiveRe
for (auto &surface : surfaces)
{
if (surface-
{
}
}
}
is unsafe; if the callback calls into SurfaceStack:
Changed in mir: | |
importance: | Undecided → Medium |
To post a comment you must log in.
Yes; in theory. In practice it might be simpler to just document that callbacks should not modify the list.
To iterate efficiently and support callbacks that can delete entries you ideally want a callback that returns a flag to tell the loop to do the deletion (and update the iterator appropriately).