Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
cloning to rhel
+++ This bug was initially created as a clone of Bug #1002383 +++
Description of problem:
In function libvirt_lxc_virDomainLxcOpenNamespace, the fdlist gotten by virDomainLxcOpenNamespace was converted to a Python List, which is initiated by PyList_New with a size of fdlist. Then each fd from fdlist is append to the Python List, which will make the python list size double of the fdlist length.
Version-Release number of selected component (if applicable):
1.0.2
How reproducible:
make a gdb debug
Steps to Reproduce:
1. write a python program to call libvirt_lxc.lxcOpenNamespace and set a pdb breakpoint.
2. gdb attach to the python process.
3. Then through gdb you will see the whole process Just as Actual results show.
Actual results:
gdb) l libvirt-lxc-override.c:58,85
58 static PyObject *
59 libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
60 PyObject *args) {
61 PyObject *py_retval;
62 virDomainPtr domain;
63 PyObject *pyobj_domain;
64 unsigned int flags;
65 int c_retval;
66 int *fdlist = NULL;
67 size_t i;
68
69 if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainLxcOpenNamespace",
70 &pyobj_domain, &flags))
71 return NULL;
72 domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
73
74 if (domain == NULL)
75 return VIR_PY_NONE;
76 LIBVIRT_BEGIN_ALLOW_THREADS;
77 c_retval = virDomainLxcOpenNamespace(domain, &fdlist, flags);
78 LIBVIRT_END_ALLOW_THREADS;
79
80 if (c_retval < 0)
81 return VIR_PY_NONE;
82
83 py_retval = PyList_New(c_retval);
84 for (i = 0; i < c_retval; i++) {
85 PyObject *item = NULL;
(gdb) l libvirt-lxc-override.c:58,99
58 static PyObject *
59 libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
60 PyObject *args) {
61 PyObject *py_retval;
62 virDomainPtr domain;
63 PyObject *pyobj_domain;
64 unsigned int flags;
65 int c_retval;
66 int *fdlist = NULL;
67 size_t i;
68
69 if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainLxcOpenNamespace",
70 &pyobj_domain, &flags))
71 return NULL;
72 domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
73
74 if (domain == NULL)
75 return VIR_PY_NONE;
76 LIBVIRT_BEGIN_ALLOW_THREADS;
77 c_retval = virDomainLxcOpenNamespace(domain, &fdlist, flags);
78 LIBVIRT_END_ALLOW_THREADS;
79
80 if (c_retval < 0)
81 return VIR_PY_NONE;
82
83 py_retval = PyList_New(c_retval);
84 for (i = 0; i < c_retval; i++) {
85 PyObject *item = NULL;
86
87 if ((item = PyInt_FromLong(fdlist[i])) == NULL)
88 goto error;
89
90 if (PyList_Append(py_retval, item) < 0) {
91 Py_DECREF(item);
92 goto error;
93 }
94 }
95 return py_retval;
96
97 error:
98 for (i = 0; i < c_retval; i++) {
99 VIR_FORCE_CLOSE(fdlist[i]);
(gdb) b libvirt-lxc-override.c:83
Breakpoint 1 at 0x7ff6c8bc4db2: file libvirt-lxc-override.c, line 83.
(gdb) b libvirt-lxc-override.c:95
Breakpoint 2 at 0x7ff6c8bc4e5b: file libvirt-lxc-override.c, line 95.
(gdb) c
Continuing.
Breakpoint 1, libvirt_lxc_virDomainLxcOpenNamespace (self=0x0, args=0x2ead3b0) at libvirt-lxc-override.c:83
83 py_retval = PyList_New(c_retval);
(gdb) n
84 for (i = 0; i < c_retval; i++) {
(gdb) p PyList_Size(py_retval)
$1 = 5
(gdb) c
Continuing.
Breakpoint 2, libvirt_lxc_virDomainLxcOpenNamespace (self=0x0, args=0x2ead3b0) at libvirt-lxc-override.c:95
95 return py_retval;
(gdb) p PyList_Size(py_retval)
$2 = 10
(gdb)
Expected results:
Above at the end, the PyList_Size(py_retval) should be 5.
Additional info:
--- Additional comment from Eric Blake on 2013-08-29 06:54:43 MDT ---
Will be fixed in 1.1.2:
commit c26181495f3c98870d0794052246718f5d3d8dd6
Author: Guan Qiang <hzguanqiang.com>
Date: Thu Aug 29 19:02:25 2013 +0800
python: Fix a PyList usage mistake
Fix PyList usage mistake in Function libvirt_lxc_virDomainLxcOpenNamespace.
https://bugzilla.redhat.com/show_bug.cgi?id=1002383
Signed-off-by: Eric Blake <eblake>
libvirt-1.1.1-4.el7
Same steps with Comment 2:
# python test.py test
The fd length=6
fd=[13, 14, 15, 16, 17, 18]
The fd's length equals to the length of fd , so set VERIFIED
This request was resolved in Red Hat Enterprise Linux 7.0.
Contact your manager or support representative in case you have further questions about the request.