Message ID | 1604531775-44045-1-git-send-email-u9012063@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] ovs-bugtool: Fix crash when enable --ovs. | expand |
On 11/4/2020 3:16 PM, William Tu wrote: > When enabling '--ovs' or when not using '-y', ovs-bugtool crashes due to > Traceback (most recent call last): > File "/usr/local/sbin/ovs-bugtool", line 1410, in <module> > sys.exit(main()) > File "/usr/local/sbin/ovs-bugtool", line 690, in main > for (k, v) in data.items(): > RuntimeError: dictionary changed size during iteration > > The patch fixes it by making a copy of the key and value. > > VMware-BZ: #2663359 > Signed-off-by: William Tu <u9012063@gmail.com> > --- > utilities/bugtool/ovs-bugtool.in | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/ovs-bugtool.in > index ddb5bc8dc54c..3792502e7a0c 100755 > --- a/utilities/bugtool/ovs-bugtool.in > +++ b/utilities/bugtool/ovs-bugtool.in > @@ -687,7 +687,7 @@ exclude those logs from the archive. > CAP_OPENVSWITCH_LOGS, CAP_NETWORK_CONFIG] > ovs_info_list = ['process-tree'] > # We cannot use iteritems, since we modify 'data' as we pass through > - for (k, v) in data.items(): > + for (k, v) in list(data.items()): > cap = v['cap'] > if 'filename' in v: > info = k[0] > @@ -708,7 +708,7 @@ exclude those logs from the archive. > > # permit the user to filter out data > # We cannot use iteritems, since we modify 'data' as we pass through > - for (k, v) in data.items(): > + for (k, v) in list(data.items()): > cap = v['cap'] > if 'filename' in v: > key = k[0] > I didn't test it but the patch does what you say it does. It should work to prevent the traceback. Acked-by: Greg Rose <gvrose8192@gmail.com>
On 11/5/20 12:54 AM, Gregory Rose wrote: > > On 11/4/2020 3:16 PM, William Tu wrote: >> When enabling '--ovs' or when not using '-y', ovs-bugtool crashes due to >> Traceback (most recent call last): >> File "/usr/local/sbin/ovs-bugtool", line 1410, in <module> >> sys.exit(main()) >> File "/usr/local/sbin/ovs-bugtool", line 690, in main >> for (k, v) in data.items(): >> RuntimeError: dictionary changed size during iteration >> >> The patch fixes it by making a copy of the key and value. >> >> VMware-BZ: #2663359 >> Signed-off-by: William Tu <u9012063@gmail.com> >> --- >> utilities/bugtool/ovs-bugtool.in | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/ovs-bugtool.in >> index ddb5bc8dc54c..3792502e7a0c 100755 >> --- a/utilities/bugtool/ovs-bugtool.in >> +++ b/utilities/bugtool/ovs-bugtool.in >> @@ -687,7 +687,7 @@ exclude those logs from the archive. >> CAP_OPENVSWITCH_LOGS, CAP_NETWORK_CONFIG] >> ovs_info_list = ['process-tree'] >> # We cannot use iteritems, since we modify 'data' as we pass through >> - for (k, v) in data.items(): >> + for (k, v) in list(data.items()): >> cap = v['cap'] >> if 'filename' in v: >> info = k[0] >> @@ -708,7 +708,7 @@ exclude those logs from the archive. >> # permit the user to filter out data >> # We cannot use iteritems, since we modify 'data' as we pass through >> - for (k, v) in data.items(): >> + for (k, v) in list(data.items()): >> cap = v['cap'] >> if 'filename' in v: >> key = k[0] >> > > I didn't test it but the patch does what you say it does. It > should work to prevent the traceback. > > Acked-by: Greg Rose <gvrose8192@gmail.com> Thanks! I updated the comment a bit and applied to master. Backported down to 2.13. Best regards, Ilya Maximets.
diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/ovs-bugtool.in index ddb5bc8dc54c..3792502e7a0c 100755 --- a/utilities/bugtool/ovs-bugtool.in +++ b/utilities/bugtool/ovs-bugtool.in @@ -687,7 +687,7 @@ exclude those logs from the archive. CAP_OPENVSWITCH_LOGS, CAP_NETWORK_CONFIG] ovs_info_list = ['process-tree'] # We cannot use iteritems, since we modify 'data' as we pass through - for (k, v) in data.items(): + for (k, v) in list(data.items()): cap = v['cap'] if 'filename' in v: info = k[0] @@ -708,7 +708,7 @@ exclude those logs from the archive. # permit the user to filter out data # We cannot use iteritems, since we modify 'data' as we pass through - for (k, v) in data.items(): + for (k, v) in list(data.items()): cap = v['cap'] if 'filename' in v: key = k[0]
When enabling '--ovs' or when not using '-y', ovs-bugtool crashes due to Traceback (most recent call last): File "/usr/local/sbin/ovs-bugtool", line 1410, in <module> sys.exit(main()) File "/usr/local/sbin/ovs-bugtool", line 690, in main for (k, v) in data.items(): RuntimeError: dictionary changed size during iteration The patch fixes it by making a copy of the key and value. VMware-BZ: #2663359 Signed-off-by: William Tu <u9012063@gmail.com> --- utilities/bugtool/ovs-bugtool.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)