Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1913465
Summary: | createrepo_c segfault when attempting to print PrimaryXmlFile or PrimarySqlite object after closing | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | Ryan Mullett <rmullett> | ||||
Component: | createrepo_c | Assignee: | Nobody <nobody> | ||||
Status: | VERIFIED --- | QA Contact: | Jan Blazek <jblazek> | ||||
Severity: | low | Docs Contact: | |||||
Priority: | low | ||||||
Version: | 8.3 | CC: | fhirtz | ||||
Target Milestone: | rc | Keywords: | Triaged | ||||
Target Release: | 8.0 | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | createrepo_c-0.17.2-1.el8 | Doc Type: | If docs needed, set a value | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | Type: | Bug | |||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | 1951406 | ||||||
Bug Blocks: | |||||||
Attachments: |
|
One additional check that was performed, which I neglected to add to initial description is below. This is simply to illustrate that the issue is not the check_XmlFileStatus(). That function is working correctly for other functions which do call it: # python3 -c 'import createrepo_c; p = createrepo_c.PrimaryXmlFile("backup-primary.xml"); p.close(); p.set_num_of_pkgs(5)' Traceback (most recent call last): File "<string>", line 1, in <module> createrepo_c.CreaterepoCError: Improper createrepo_c XmlFile object (Already closed file?). Upstream fix: https://github.com/rpm-software-management/createrepo_c/commit/c752fc09d139224331328e4e02912d68ac225dcc The previous PR was fixing just xmlfile I have made another one which also fixes sqlite and it prints the representation of a closed xmlfile/sqlite instead of throwing an exception. In addition it adds unit test testing. https://github.com/rpm-software-management/createrepo_c/pull/257 |
Created attachment 1745041 [details] segfault from RHEL 8 test system illustrating the issue Description of problem: After calling the .close() method on a PrimaryXmlFile or PrimarySqlite object, calling __repr__ or __str__ results in a coredump Version-Release number of selected component (if applicable): createrepo_c-libs-0.15.11-2.el8.x86_64 python3-createrepo_c-0.15.11-2.el8.x86_64 Issue appears to be present in every release across 7 and 8. How reproducible: Always Steps to Reproduce: Example 1: # python3 -c 'import createrepo_c; p = createrepo_c.PrimarySqlite("primary.sqlite"); p.close(); p.__str__()' Segmentation fault (core dumped) Example 2: # python3 -c 'import createrepo_c; p = createrepo_c.PrimarySqlite("primary.sqlite"); p.close(); p.__repr__()' Segmentation fault (core dumped) Example 3: # python3 -c 'import createrepo_c; p = createrepo_c.PrimaryXmlFile("primary.xml"); p.close(); p.__str__()' Segmentation fault (core dumped) Example 4: # python3 -c 'import createrepo_c; p = createrepo_c.PrimaryXmlFile("primary.xml"); p.close(); p.__repr__()' Segmentation fault (core dumped) Actual results: Segfault Expected results: After closing, the object should still be available to be read, as is standard for other python modules. For example: # python -c 'p = open("items.xml"); p.close(); print(p.__str__())' <_io.TextIOWrapper name='items.xml' mode='r' encoding='UTF-8'> Additional info: Looking around it appears that other methods that are fully implemented via this library go through a check to see if the object was already closed. They go through check_XmlFileStatus(): static int check_XmlFileStatus(const _XmlFileObject *self) { assert(self != NULL); assert(XmlFileObject_Check(self)); if (self->xmlfile == NULL) { PyErr_SetString(CrErr_Exception, "Improper createrepo_c XmlFile object (Already closed file?)."); return -1; } return 0; } However, the __repr__ and __str__ do not. This results in a segfault when they try to access the object which is NULL after having been closed.