_______________________________________________Package: htcondor-python-binding
Version: 8.7.8
Severity: normal
Â
Hi,
Â
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()[0].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.
Â
Cheers,
Mingxuan Lin
Â
HTCondor-users mailing list
To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a
subject: Unsubscribe
You can also unsubscribe by visiting
https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users
The archives can be found at:
https://lists.cs.wisc.edu/archive/htcondor-users/