Installation of Swi-Prolog and running examples

I use Ubuntu 18.04 64bit

I installed Prolog via PPA

sudo apt-get install swi-prolog

sudo apt-get install swi-prolog-java

Installation is OK
check_installation. outputs all OK.

When I try to run JPL examples, FamilyMT fails.
I need to make this example run successfully, because the same error occurs also in my diploma thesis Java Program using JPL.

FamilyMT console run output:

JPL demo: FamilyMT

consult succeeded
spawning client[0]
spawning client[1]
spawning client[2]
spawning client[3]# A fatal error has been detected by the Java Runtime Environment:

#  SIGSEGV (0xb) at pc=0x00007f578d1074b2, pid=3007, tid=0x00007f576caf6700
# JRE version: OpenJDK Runtime Environment (8.0_191-b12) (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  []  PL_thread_attach_engine+0xe2
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
# An error report file with more information is saved as:
# /home/kech/Documents/prolog_sources/prolog7.6.4/swipl-devel/packages/jpl/examples/java/FamilyMT/hs_err_pid3007.log
spawning client[4]
spawning client[5]
spawning client[6]
spawning client[7]
spawning client[8]
spawning client[9]
spawning client[10]
spawning client[11]
spawning client[12]
spawning client[13]
spawning client[14]
spawning client[15]
spawning client[16]
spawning client[17]
spawning client[18]
spawning client[19]
# If you would like to submit a bug report, please visit:
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
Aborted (core dumped)

Please I desperatedly need your help!! My thesis is almost complete and I want to make it work on Linux, so to upload it to a Linux Server.
I understand that it fails when it tries to create a new Thread. Can you tell me why it aborts?

@jan Is this post clear enough to define the problem?

I can reproduce the problem. I still have little clue what causes it. JPL is a very complicated beast to debug which is made even worse as gdb doesn’t understand much of Java VMs. I did test on the old stable version (7.6.4), where this test works fine (after copying the missing

I’ll have a look. Afraid I can’t promise much.

Thank you very much.
You mean that this problem happens to you as well??

Yes. Pushed 714e9eabd25bb902395838a08dc9f7eaebadfe6f to fix this and a96724bdcd716bcbc9e3743d9cedfa2291b85be9 to make work in the examples directory.

In other words, either install from the current swipl-devel.git or the old stable 7.6.4 release and you should be fine. Success with your thesis!

@jan Thank you, i checking it now…
Do I have to set LD_PRELOAD also?

You need LD_PRELOAD if you want to load foreign extensions into the Prolog image. If you do not know, try without. If loading a library you need results in a linker error and abort of the process you need it. It should point at

It worked well
Thank you @jan

Hi guys,

Good I found this! I worked with SWI-JPL in versions 7.6.x with success.

With Jan and others, we have many improvements to the JPL Java interface (jpl.jar) that were included in the SWI 8.x.x version. So I just managed to have time to upgrade my SWI system to it; and I encounter this exact problem: crashes.

I added an issue on that:

@Jan, it seems you have pushed a fix for this into git? That would be amazing. I will check that now and close my issue in that case.

Jan, tried to get a clean git install of SWI to double check it works, but the CMAKE compile breaks:

Have checked with the new version in the git repo and it is fixed, thanks Jan.

@stisko, just be aware that if you use 7.6.4 (which does not have this issue) you will be using an old JPL Java interface (jar file jpl.jar) before the several updates done and released with 8.x.x. So, some of the API will not work as stated in JPL doc; for example the old implementation of the next solution iterator was not as standard in Java. Just so that you are aware.

I got the git version, compiled everything and I don’t get the crash anymore. Thanks a lot Jan for doing that fix so quickly!