get_segment_info leaks reference count for items
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Object Storage (swift) |
Invalid
|
Undecided
|
Unassigned | ||
PyECLib |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
ECDriver.
*Current* pyeclib does like here[1]:
ret_dict = PyDict_New();
if (NULL == ret_dict) {
pyeclib_
} else {
PyDict_
PyDict_
PyDict_
PyDict_
PyDict_
}
return ret_dict;
However, the docs for Python C-Extension says, sort of Python Object conversion (e.g. PyInt_FromLong) returns *a new reference* (i.e. increment the reference)[2]. And PyDict_SetItem seems to never steal the ownership for the reference unless the PyObject values throw the reference. Hence the reference counts of those objects included in the get_segment_info return value are never decremented, therefore they can not be collected as garbage.
An example to set items to the dict is available here [3]:
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_
int i = PyInt_AS_
PyObject *o = PyInt_FromLong(i);
if (o == NULL)
return -1;
if (PyDict_
return -1;
}
Py_DECREF(o);
}
That needs Py_DECREF explicitly for each PyObject items of the dict.
With [4] code, I made sure the reference count increasing. (Note that it needs debug mode python built with --with-pydebug) And then, a patch I will attach the link for gerrit obviously prevent the ref count increasing.
In Swift perspective, PUT/GET objects against to EC policy containers are affected.
GET objects are always affected since EC supported. PUT objects are affected only if the requests has content-length and affected versions have been since https:/
1: https:/
2: https:/
3: https:/
4: https:/
description: | updated |
Patch is here, https:/ /review. openstack. org/#/c/ 344066/