Repository navigation
mgr: fix PyObject leak in the remote() pickle calls - #69755
Conversation
|
the reason why valgrind qa run failed to flag it: Lines 825 to 832 in 96e268b |
dispatch_remote() and ceph_dispatch_remote() invoke pickle.loads/dumps via
PyObject_CallMethodObjArgs(pmodule, PyUnicode_FromString("loads"), ...). The
method-name string created by PyUnicode_FromString is a new reference that
CallMethodObjArgs does not steal, and it was never released, so every cross
-module remote() call leaked three PyUnicode objects on the active mgr.
Use PyObject_CallMethod(pmodule, "loads", "(O)", arg), which takes the method
name as a C string and manages it internally, so there is nothing to leak.
The "(O)" format wraps the argument in a one-tuple so it reaches the callee as
a single object. A bare "O" passes the argument through directly, and when it
is a tuple (as remote()'s *args always is, including the empty tuple from a
no-argument call) PyObject_CallMethod unpacks it and calls dumps() with the
wrong arguments, e.g. dumps() with none.
Fixes: https://tracker.ceph.com/issues/77724
Signed-off-by: Kefu Chai <[email protected]>
a4eaaf0 to
8ae44f6
Compare
|
lgtm |
@mheler hi Matthew, thanks for reviewing and approving this change. in addition to commenting it, could you actually approve this change by "approving" it in github? otherwise we cannot merged this change, even it passes the integration tests. |
|
@tchaikov: I'm curious, how are we catching these? Aren't we enabling valgrind on some test runs? This should? be easy to catch even with simple vstart testing, as long as all mgr API calls are invoked. |
|
@epuertat i am afraid that valgrind cannot flag a "leak" like this, because we practically prevent valgrind / ASan from identifying these leaks with suppression rules see Lines 15 to 41 in 40e8ea0 i implemented a |
|
@tchaikov interesting! And why are we suppressing those? I did a quick AI chat and got the following ideas:
And I can check that PR too! |
dispatch_remote()andceph_dispatch_remote()invoke pickle.loads/dumps viaPyObject_CallMethodObjArgs(pmodule, PyUnicode_FromString("loads"), ...). The method-name string created byPyUnicode_FromStringis a new reference thatCallMethodObjArgsdoes not steal, and it was never released, so every cross -moduleremote()call leaked three PyUnicode objects on the active mgr.Use
PyObject_CallMethod(pmodule, "loads", "O", arg), which takes the method name as a C string and manages it internally, so there is nothing to leak.Fixes: https://tracker.ceph.com/issues/77724
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.