Commit f4de4bf5 authored by zen's avatar zen

Patch Python's weakref module in translation platform

This is an ugly workaround to get rid of noise in tails-translations
mailing list.

The Python version in Debian Stretch has a bug that leaks memory in some
situations and will spit out the following error:

------------------------------------------------------------------------------
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fe488c03048>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fe488c03048>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f69c5515ea0>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f69c5515ea0>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
------------------------------------------------------------------------------

As our scripts run frequently, we are getting many e-mails that are
actually false positives.

The differences from the original file are:

------------------------------------------------------------------------------
--- weakref.py  2020-07-28 22:54:59.837435324 +0000
+++ /usr/lib/python3.5/weakref.py       2020-07-09 13:00:10.000000000 +0000
@@ -106,7 +106,7 @@
         self, *args = args
         if len(args) > 1:
             raise TypeError('expected at most 1 arguments, got %d' % len(args))
-        def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
+        def remove(wr, selfref=ref(self)):
             self = selfref()
             if self is not None:
                 if self._iterating:
@@ -114,7 +114,7 @@
                 else:
                     # Atomic removal is necessary since this function
                     # can be called asynchronously by the GC
-                    _atomic_removal(d, wr.key)
+                    _remove_dead_weakref(d, wr.key)
         self._remove = remove
         # A list of keys to be removed
         self._pending_removals = []
------------------------------------------------------------------------------

See the following links for more context:

    https://helpdesk.tetrane.com/hc/en-us/articles/360034629091-I-am-getting-exceptions-from-usr-lib-python3-5-weakref-py-is-it-an-issue-
    https://bugs.python.org/issue29519

This will have to be removed once the machine is upgraded to a newer
Debian version.
parent 07003afc
This diff is collapsed.
......@@ -35,4 +35,21 @@ class tails::weblate::debian_packages () {
ensure_packages($packages)
# The following file is a slightly patched version of the original one to
# address a memory leak that spits out unharmful (but annoying) exceptions
# every once in a while. We need that to avoid noise in our custom Python
# scripts.
#
# TODO: remove once the VM is upgraded to a newer version of Debian.
ensure_packages(['libpython3.5-minimal'])
file { '/usr/lib/python3.5/weakref.py':
source => 'puppet:///modules/tails/weblate/python/weakref.py',
mode => '0644',
owner => root,
group => root,
require => Package['libpython3.5-minimal'],
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment