Thank you for your introduction about _xxsubinterpreters, Eric.
This particular leak is easy: it's right in _channel_send(). I've submitted a PR.
I've also done a quick scan of neighboring code, and it seems there are other leaks as well, e.g.:
* PyThread_free_lock() is not called at https://github.com/python/cpython/blob/dcb68f47f74b0cc8a1896d4a4c5a6b83c0bbeeae/Modules/_xxsubinterpretersmodule.c#L761 (and below)
* data is not released and freed at https://github.com/python/cpython/blob/dcb68f47f74b0cc8a1896d4a4c5a6b83c0bbeeae/Modules/_xxsubinterpretersmodule.c#L1387
Do you think it'd make sense to go through the module to find and fix leaks? Or is this code in an early stage for such cleanup?
As a side note, such leaks should be easily found by static analyzers such as Coverity (assuming it understands CPython allocation functions like PyMem_NEW), so it might make sense to check out its reports on the module. |