logic-and-learning-lab/Popper

Problem with SWI Prolog's new stable PPA version 9.0.0 (Linux Ubuntu)

hakank opened this issue · 4 comments

Yesterday, SWI Prolog's stable PPA version was updated to version 9.0.0 (from v8.4.3) and now Popper does work:

$ python3 popper.py examples/alleven
[Thread 1 (main) at Fri Nov 25 10:52:17 2022] /build/swi-prolog-hvyroz/swi-prolog-9.0.0-1-g0757fd884/src/pl-fli.c:2637: PL_put_chars: Assertion failed: 0
C-stack trace labeled "assert_fail":
  [0] PL_scan_options() at ??:? [0x7f692f994a98]
  [1] PL_unify_mpq() at ??:? [0x7f692f951fdf]
  [2] PL_put_chars() at ??:? [0x7f692f97582d]
  [3] ffi_call_unix64() at ??:? [0x7f6941588dec]
  [4] ffi_call() at ??:? [0x7f6941587f55]
  [5] _call_function_pointer() at /home/hakank/python/Python-3.7.6/Modules/_ctypes/callproc.c:850 [0x7f693dce0079]
  [6] PyCFuncPtr_call() at /home/hakank/python/Python-3.7.6/Modules/_ctypes/_ctypes.c:4017 [0x7f693dcdd0c3]
  [7] python3(_PyObject_FastCallKeywords+0x92) [0x561a29bf4ea2]
  [8] python3(_PyEval_EvalFrameDefault+0x4935) [0x561a29c65e75]
  [9] python3(+0x1c4658) [0x561a29cbf658]
  [10] python3(+0x16526a) [0x561a29c6026a]
  [11] python3(_PyMethodDef_RawFastCallKeywords+0xe9) [0x561a29bf4529]
  [12] python3(_PyCFunction_FastCallKeywords+0x20) [0x561a29bf4420]
  [13] python3(_PyEval_EvalFrameDefault+0x4643) [0x561a29c65b83]
  [14] python3(_PyEval_EvalCodeWithName+0x2de) [0x561a29c60afe]
  [15] python3(_PyFunction_FastCallKeywords+0x1bc) [0x561a29bf607c]
  [16] python3(_PyEval_EvalFrameDefault+0x49eb) [0x561a29c65f2b]
  [17] python3(_PyObject_Call_Prepend+0x2db) [0x561a29bf68fb]
  [18] python3(+0x13aea9) [0x561a29c35ea9]
  [19] python3(+0x137b94) [0x561a29c32b94]
  [20] python3(_PyObject_FastCallKeywords+0x92) [0x561a29bf4ea2]
  [21] python3(_PyEval_EvalFrameDefault+0x4935) [0x561a29c65e75]
  [22] python3(_PyEval_EvalCodeWithName+0x6a3) [0x561a29c60ec3]
  [23] python3(_PyFunction_FastCallDict+0x300) [0x561a29b5a600]
  [24] python3(_PyEval_EvalFrameDefault+0x1bc7) [0x561a29c63107]
  [25] python3(_PyEval_EvalCodeWithName+0x6a3) [0x561a29c60ec3]
  [26] python3(_PyFunction_FastCallKeywords+0x248) [0x561a29bf6108]
  [27] python3(_PyEval_EvalFrameDefault+0x13ad) [0x561a29c628ed]
  [28] python3(_PyFunction_FastCallKeywords+0xf2) [0x561a29bf5fb2]
  [29] python3(_PyEval_EvalFrameDefault+0x64d) [0x561a29c61b8d]
  [30] python3(_PyEval_EvalCodeWithName+0x2de) [0x561a29c60afe]
  [31] python3(PyEval_EvalCode+0x23) [0x561a29c60813]
  [32] python3(+0x208f22) [0x561a29d03f22]
  [33] python3(PyRun_FileExFlags+0x9d) [0x561a29d042ed]
  [34] python3(PyRun_SimpleFileExFlags+0x1b6) [0x561a29d040f6]
  [35] python3(+0x1dfe44) [0x561a29cdae44]
  [36] python3(_Py_UnixMain+0x3c) [0x561a29cdaadc]
addr2line: DWARF error: section .debug_info is larger than its filesize! (0x93ef57 vs 0x530ea0)
  [37] __libc_start_main() at ??:? [0x7f6942d77083]
  [38] python3(_start+0x2a) [0x561a29cda9ba]
[1]    44398 abort (core dumped)  python3 popper.py examples/alleven

So it seems that there is a problem with the pyswip package (again), and I'm trying to find a way to downgrade to the previous SWI Prolog stable PPA version.

(I also tried to downgrade the pyswip version, but all the versions I tried - 0.2,9, 0..2.10, 0.2.11 - yield some error.)

I asked about downgrading at the SWI Prolog forum: https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966 .

For me it worked by downloading the appropriate .deb files from https://launchpad.net/~swi-prolog/+archive/ubuntu/stable/+build/24099974 (the focal distribution for Ubuntu 20.05) and then installing them in correct order:

sudo dpkg -i swi-prolog-nox_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb
sudo dpkg -i swi-prolog-x_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb
sudo dpkg -i swi-prolog_8.4.3-1-g10c53c6e3-focalppa2_amd64.deb

Even if this fix works, it's an issue that I hope will be fixed so we can use the current stable SWI Prolog version.

There is a simple fix that seems to solve the problem (which I reported in https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/9), namely to change the pyswip source according to this diff:

diff --git a/pyswip/core.py b/pyswip/core.py
index 33f7035..0bb992f 100644
--- a/pyswip/core.py
+++ b/pyswip/core.py
@@ -584,7 +584,7 @@ PL_VERSION_VM               =6      # VM signature
 PL_VERSION_BUILT_IN    =7      # Built-in predicate signature
 
 try:
-    PL_version = _lib.PL_version
+    PL_version = _lib.PL_version_info
     PL_version.argtypes = [c_int]
     PL_version.restype = c_uint

So now Popper works with SWI Prolog version 9.0.0 (stable PPA version).

(This was inspired by the PR 133 at pyswip: yuce/pyswip#133 )

Posting my simple solution here:

I faced the same issue on my Mac M1. When i upgraded Prolog I faced the same issue. Popper was not working any more.

I had installed pyswip through Homebrew. All I had to do was:

locate pyswip core.py file:
for me it was in /opt/homebrew/lib/python3.10/site-packages/pyswip

change PL_version = _lib.PL_version (in line 587)
to PL_version = _lib.PL_version_info

This got Popper working again

Solution inspired by (https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966/18)

@hakank @youssefmahmoud89

Thanks for posting this issue. The master branch of pyswip now works correctly with the latest version of Prolog.