You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As show above, the last line resolvers += self.yaml_implicit_resolvers.get(None, []) in resolve will change the yaml_implicit_resolvers inplace by accident, making yaml_implicit_resolvers size become more and more bigger, the yaml.dump will slow down, and finally use up 100% CPU.
reproduce:
importreimportyamldeftest_implicit_resolver_leak():
# Add any custom resolvertag, regexp='!any_resolver', re.compile('AnyResolver')
yaml.add_implicit_resolver(tag, regexp)
none_resolvers=yaml.Dumper.yaml_implicit_resolvers.get(None, [])
assert (tag, regexp) innone_resolversold_f_resolvers=yaml.Dumper.yaml_implicit_resolvers.get('f', [])
assert (tag, regexp) notinold_f_resolvers# Dump at least one ScalarNodeyaml.dump(False)
new_f_resolvers=yaml.Dumper.yaml_implicit_resolvers.get('f', [])
assert (tag, regexp) innew_f_resolvers# leak here
The text was updated successfully, but these errors were encountered:
xqliang
changed the title
yaml.dump increase implicit resolver by accident, and finally use up 100% CPU
yaml implicit resolver leak
Aug 8, 2017
xqliang
pushed a commit
to xqliang/pyyaml
that referenced
this issue
Aug 8, 2017
Every time when we call
yaml.dump
, it will call theresolve
method:As show above, the last line resolvers += self.yaml_implicit_resolvers.get(None, []) in
resolve
will change theyaml_implicit_resolvers
inplace by accident, makingyaml_implicit_resolvers
size become more and more bigger, theyaml.dump
will slow down, and finally use up 100% CPU.reproduce:
The text was updated successfully, but these errors were encountered: