From fa58ab7b297d1df467ac3a4b77397b3ca05325e9 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 30 Nov 2015 15:19:22 +0100 Subject: Limit the number of inferences for Prolog queries --- prolog/engine.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'prolog') diff --git a/prolog/engine.py b/prolog/engine.py index bd1fb1d..d61c43b 100644 --- a/prolog/engine.py +++ b/prolog/engine.py @@ -132,8 +132,11 @@ def check_answers(engine, query, answers, timeout=10): start = time.monotonic() try: + # Limit inferences for each solution to curb unbounded recursion. + limited = '''(call_with_inference_limit(({}), 100000, _ILR), + _ILR \= inference_limit_exceeded)'''.format(query) # Run the query. - reply, output = ask(engine, query, timeout) + reply, output = ask(engine, limited, timeout) answer, error, more = process_answer(reply) if not check_answer(answer): return False -- cgit v1.2.1