yuce / pyswip

PySwip is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
MIT License
464 stars 97 forks source link

Errors on queries #127

Open Jazzpirate opened 3 years ago

Jazzpirate commented 3 years ago

I'm getting a weird bug that I have no idea how to resolve or even properly identify.

My prolog KB provides a clause add_item/2 that (ultimately) adds a new item to the knowledge base. I call this in my python main method with prolog.query() for an initial item, everything works fine, I get back something and calling list() on the return gives me {}. Great. Doing the same with another item i2 right afterwards does the same.

But. When I do the query-call for i2 later, in the constructor method of a class of mine (where it ultimately should happen), it doesn't work. In a normal run, calling list() on the returned value kills the program with a segmentation fault. In debug mode, evaluating list() in the debugger shell prints No more messages and the program is being killed.

Any ideas what's going on here?