getsentry / raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
https://sentry.io
BSD 3-Clause "New" or "Revised" License
1.68k stars 657 forks source link

varmap can cause crashes in multithreaded programs #1343

Open amol- opened 5 years ago

amol- commented 5 years ago

As varmap uses iteritems: https://github.com/getsentry/raven-python/blob/03559bb05fd963e2be96372ae89fb0bce751d26d/raven/utils/basic.py#L45

It can lead to crashes under multithreaded programs that might modify the dictionary variables concurrently while a message is being reported.

File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/base.py", line 799, in captureMessage
  return self.capture('raven.events.Message', message=message, **kwargs)
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/base.py", line 641, in capture
  **kwargs)
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/base.py", line 476, in build_msg
  data.update(processor.process(data))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/processors.py", line 39, in process
  data['extra'] = self.filter_extra(data['extra'])
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/processors.py", line 135, in filter_extra
  return varmap(self.sanitize, data)
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 52, in varmap
  for k, v in iteritems(var))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 52, in <genexpr>
  for k, v in iteritems(var))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 47, in varmap
  ret = [varmap(func, f, context, name) for f in var]
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 52, in varmap
  for k, v in iteritems(var))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 52, in <genexpr>
  for k, v in iteritems(var))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 52, in varmap
  for k, v in iteritems(var))
File "/var/lib/crunch.io/venv/lib/python2.7/site-packages/raven/utils/__init__.py", line 51, in <genexpr>
  ret = dict((k, varmap(func, v, context, k))
RuntimeError: dictionary changed size during iteration