Re #10031. Make sure iterators are valid.