Open thozza opened 1 month ago
Note: this still needs to be triaged, I am just adding notes from our previous 1-1 conversation to provide context.
Me: My assumption is that the owner of the packages objects is the transaction which is destroyed when going out of scope, so you might probably need to keep the whole transaction object. Or maybe you would need to keep a reference to the whole base.
Reporter: I'd expect the Package object to keep any references it needs to work.
Me: I agree that would be the better and user friendly, I am just not sure if this could be resolved easily as the Python bindings are generated by SWIG. We will get back to you in the upstream issue.
In https://github.com/osbuild/osbuild, we have executables which wrap DNF (4 and 5) Python APIs, that we use for depsolving package sets that are then installed as part of OS image building process.
One of the recently added functionality is to generate SPDX SBOM documents for the depsolved transaction. This is done by transforming the depsolving result, specifically package metadata and their relationships, into the respective SPDX SBOM model. The transformation is implemented by a library function, which accepts
List[dnf.package.Package]
orList[libdnf5.rpm.Package]
and extracts the necessary data from the package objects.However, calling any methods on the
libdnf5.rpm.Package
objects outside of the scope of the function, which depsolved the original transaction, triggers a core dump due to invalid pointer dereference:The reproducer is attached below. Maybe I'm not using the API correctly, but the documentation is not really helpful in figuring this out.
The behavior is consistent with:
Reproducer