Igalia / snabb

Snabb Switch: Fast open source packet processing
Apache License 2.0
48 stars 5 forks source link

Plug various resource leaks in context of (re)configuration #1228

Closed eugeneia closed 4 years ago

eugeneia commented 4 years ago

This PR consists of a number of fixes for resource leaks that became apparant after a sufficient number of re-configurations as exercised in #1221.

There are two classes of bugs here. The first, leaking ctypes (as well as memory used for non-GCed backing code from code-gen) was caused by callers failing to memoize the results of calling our various special purpose code generators. Or more specifically, failing to memoize the results of ffi.typeof(...) expressions that allocate new ctype IDs.

This PR fixes these by implementing the memoization at the roots of the problems, as opposed to relying on callers to account for resource management (prone to error).

The second class is lib.yang auxiliary functions creating temporary files in /var/run but failing to eventually unlink those. This eventually results in write errors to the typically ramfs backed storage which eventually fills up (“no space left on device”).

Fixes #1221

dpino commented 4 years ago

Great work! I don't know why snabb-test is failing, apparently it's a failure in a NIC. I will try to take a look.