libdnf
libdnf copied to clipboard
Core dump upon exit after creating a libdnf.repo.Repo
[vagrant@bodhi-dev delme]$ python3 -c "import libdnf; libdnf.repo.Repo('test', libdnf.conf.ConfigRepo(libdnf.conf.ConfigMain()))"
double free or corruption (fasttop)
Aborted (core dumped)
[vagrant@bodhi-dev delme]$ rpm -q libdnf
libdnf-0.31.0-2.fc29.x86_64
In this case is "problem" that C++ Repo class takes ownership of ConfigRepo object. The object is released from memory twice. Once by the Repo class and once by the Python gargabe colector. We have to take ownership from Python (call the disown method). The Repo is exported from C++ by swig. In C++ we have unique_ptr for this. But the new API is not finished/stable now. I'm thinking how to make API friendlier to Python programers.
Example code:
$ python3
Python 3.7.1 (default, Oct 23 2018, 18:19:07)
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libdnf
>>> mainCfg = libdnf.conf.ConfigMain()
>>> repo1Cfg = libdnf.conf.ConfigRepo(mainCfg)
>>> repo1Cfg.this.disown() # repo1 will be the owner of repo1Config
>>> repo1 = libdnf.repo.Repo('test1', repo1Cfg)
>>> repo2Cfg = libdnf.conf.ConfigRepo(mainCfg)
>>> repo2Cfg.this.disown() # repo2 will be the owner of repo2Config
>>> repo2 = libdnf.repo.Repo('test2', repo2Cfg)