-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
BUG: Fix memory leak in dtype from dict contructor #13855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thinking about using |
Py_XDECREF(names); | ||
Py_XDECREF(descrs); | ||
Py_XDECREF(offsets); | ||
Py_XDECREF(titles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK back to this version, setref is too smart/not that nice. But this just duplicates the fail path, so could avoid that. But right now that just feels like touching more code than necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names
and fields
are always null here, they're set on line 1235
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for offsets
, descrs
, and titles
, I'd be inclined to decref and null them on 1212, where they are last used.
Either than or line 1235, so all the nulling happens in one place. Py_CLEAR()
would work to combine the null and decref, althoug is a little unusual for local variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe better. The nicer pattern would be to use the same cleanup code for success and failure path I think, which is why this unnecessary decref got in. But yeah, I can just decref it all there and think about moving things some other day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I could see it either way. I'll let you make the call.
Found that strange reference count leak we were looking for Matti ;), since it is trivial pushed a fix (no test) |
@@ -32,6 +32,7 @@ npy_ctypes_check(PyTypeObject *obj) | |||
} | |||
|
|||
ret = PyObject_IsTrue(ret_obj); | |||
Py_DECREF(ret_obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a whole bunch more, I think refcount testing might be a big soon (except f2py probably), that would be awesome...
Fixes gh-13853