I encountered a bug with the python-bindings of ClassAd objects. Below are the minimal codes to reproduce the problem:
ÂÂÂÂÂÂ Python 3.6.5 | packaged by conda-forge | (default, AprÂ 6 2018, 13:39:56)
ÂÂÂÂÂÂ [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
ÂÂÂÂÂÂ >>> import htcondor, classad
ÂÂÂÂÂÂ >>> coll Â= htcondor.Collector()
ÂÂÂÂÂÂ >>> schedd= htcondor.Schedd(coll.locate(htcondor.DaemonTypes.Schedd))
ÂÂÂÂÂÂ >>> print([(k,v) for k,v in schedd.query().items()])
ÂÂÂÂÂÂ Segmentation fault (core dumped)
The root of this SEGFAULT is that the `items` method of `ClassAdWrapper` returns invalid references to its child objects. A ClassAd object usually contains some objects of nontrivial type, such as `classad.ExprTree`, which are destroyed when their parent is garbage-collected by the python runtime. Therefore trying to access such objects results in memory access violation (SEGFAULT). Here is the code section responsible for it: https://github.com/htcondor/htcondor/blob/3c73f7c8bcb9d4b99793cd3bc97251639e18b99d/src/python-bindings/classad.cpp#L993
This is a python3-only problem because the `items` method of python 3 object returns an `iterator` instead of a list of tuples.
The proposed solution is to properly transform any non-trivial child object of `ClassAdWrapper` into a python object (with its own reference counter) so that the runtime can garbage collected them correctly.
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
You can also unsubscribe by visiting
The archives can be found at: