Bug 1888343

Summary: Calling the clear method on a StrDict will cause a segfault.
Product: Red Hat Enterprise Linux 8 Reporter: sean.vinsick <sean.vinsick>
Component: libcompsAssignee: amatej
Status: CLOSED ERRATA QA Contact: Jan Blazek <jblazek>
Severity: medium Docs Contact:
Priority: high    
Version: 8.2CC: amatej, nsella, pkratoch
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libcomps-0.1.11-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:01:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sean.vinsick@gd-ms.com 2020-10-14 15:45:08 UTC
User-Agent:       Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Build Identifier: 

Calling the clear method on a StrDict will cause a segfault if converted to a string afterwards.

$ sudo dnf list installed | grep libcomps
libcomps.x86_64           0.1.11-4.el8   @rhel-8-for-x86_64-baseos-rpms
libcomps-devel.x86_64     0.1.11-4.el8   @rhel-8-for-x86_64-baseos-rpms
python3-libcomps.x86_64   0.1.11-4.el8   @rhel-8-for-x86_64-baseos-rpms

Running this as a script will cause the segfault everytime:
import libcomps
import urllib.request

url = 'http://mirror.metrocast.net/fedora/epel/8/Everything/x86_64/repodata/7566a18455054e4ce6b28bda7c181f66dd9958ed35c66f2b23612fa1f1f5c591-comps-Everything.x86_64.xml'
file_path = '/tmp/testcomp.xml'

urllib.request.urlretrieve(url, file_path)
comps = libcomps.Comps()
comps.fromxml_f(file_path)

#printing comp file works fine
print(comps.toxml_str())

#calling clear() on a StrDict
comps.categories[0].name_by_lang.clear()

# segfault occurs:
print(comps.toxml_str())

Output:
Fatal Python error: Segmentation fault

Current thread 0x00007f147aad6640 (most recent call first):
  File "<stdin>", line 1 in <module>
Segmentation fault (core dumped)






 

Reproducible: Always

Steps to Reproduce:
See above
Actual Results:  
segfault

Expected Results:  
no segfault

A work around is to create and assign a new empty StrDict object:

comps.categories[0].name_by_lang = libcomps.StrDict()

Comment 1 amatej 2020-10-22 12:10:23 UTC
Thank you for the reproducer!

PR with a fix: https://github.com/rpm-software-management/libcomps/pull/75

Since this is an API problem the PR also contains a short unittest for this situation (similar to the described reproducer).

Comment 11 errata-xmlrpc 2021-05-18 15:01:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dnf bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1657