From: Sage Weil Date: Mon, 30 Sep 2013 23:33:22 +0000 (-0700) Subject: osd/ReplicatedPG: fix iterator corruption in cancel_copy_ops() X-Git-Tag: v0.71~55^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=75b94ba2953169cd7cd458df5a0f6b844504d1f9;p=ceph.git osd/ReplicatedPG: fix iterator corruption in cancel_copy_ops() The cancel_copy() method removes the entry from copy_ops. Move the iterator forward before calling. Fixes segfault when thrashing osds with a copy-from workload. Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 5e099c0853d4..fcaca434ba89 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4583,10 +4583,9 @@ void ReplicatedPG::cancel_copy(CopyOpRef cop) void ReplicatedPG::cancel_copy_ops() { dout(10) << __func__ << dendl; - for (map::iterator p = copy_ops.begin(); - p != copy_ops.end(); - copy_ops.erase(p++)) { - cancel_copy(p->second); + map::iterator p = copy_ops.begin(); + while (p != copy_ops.end()) { + cancel_copy((p++)->second); } }