potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
601 stars 79 forks source link

Segmentation fault when iterating over Control.symbolic_atoms.by_signature() #389

Closed daveraja closed 1 year ago

daveraja commented 2 years ago

Iterating over a signature where there are no matching entries will cause a seg fault for the latest Clingo. So, the following is fine with Clingo 5.5 but seg faults with Clingo 5.6.0:

from clingo import Control, Number, String, Function, SymbolType
from clingo.ast import parse_string, ProgramBuilder

prgstr = """x(1)."""
ctrl = Control()

with ProgramBuilder(ctrl) as pb:
    parse_string(prgstr, pb.add)
ctrl.ground([("base", [])])

for sa in ctrl.symbolic_atoms.by_signature("x", 1, False):
    print(f"{sa}")
rkaminsk commented 2 years ago

Definitely a bug. Maybe something mishap when refactoring code. It should not be difficult to fix. Will take care of it tomorrow.