Ann: SWI-Prolog 8.1.32

Dear SWI-Prolog user,

I’m happy to announce SWI-Prolog 8.1.32. Various people contributed,
notably to portability issues. Highlights:

  • An atom garbage collect issue related to stack freezing was fixed
    by Keri Harris.

  • Some versions of gcc marge instruction addresses of different VMI,
    causing problems with saved states and decompilation. Found by
    Keri Harris. The patch also improves scalability of multi-threaded
    applications using these instructions.

  • Various issues compiling using MSVC on Windows by Röbke Geenen.

  • Added CMake export config to SWIPL install by Michael Welsh Duggan.

  • Lots of documentation typos fixed by Adrian Wong (website).

  • Added PL_assert(). Allows for assert{a,z}/1 from C. Suggested
    by Barry Evans.

  • Various JPL enhancements by Sebastian Sardina.

    Enjoy — Jan

SWI-Prolog Changelog since version 8.1.31

  • FIXED: rational tripwire for negative rational numbers. Rick Workman.

  • PORT: Using _BitScanReverse/_BitScanReverse64 as according to Microsoft

  • FIXED: Build for Win32: separate VMI for T_TRY_MPZ. Relates to

  • ENHANCED: save_settings/0: raise error if there is no default file
    known to save the settings.

  • CLEANUP: Remove old code for separating VMI addresses.

  • FIXED: try to ensure that compilers don’t merge identical looking
    VMI functions. Check the WAM table does not contain duplicate entries
    when Prolog is initialized.

  • FIXED: Isue#592: Help/submit bug report link. Alvin Seville.

  • MODIFIED: argv_options/3: map - in option names to _, compatible
    with SWI-Prolog’s option handling in recent versions.

  • MODIFIED: PL_unify_float() and PL_put_float() to turn any NaN into
    the Prolog canonical NaN (1.5NaN).

  • FIXED: Re-allow DCGs in sandboxed mode. Daan van Berkel.

  • PORT: Updated Large File Support in minizip to use existing CMake
    detection logic

  • DOC: Improved intro text for library(yall) intro I have added more
    explanations regarding the concept of “closure” as used in Prolog and
    extended the description of the rest. It feels better and is hopefully
    clearer to a newcomer, but in the end it’s matter of taste. I was
    unable to justify the text to 73 columns though, I just kept to this
    as close as possible,

  • FIXED: XSB emulation of parsort/4. Ed Schwartz.

  • BUILD: Don’t use single quotes around arguments to -g options,
    to remain compatible with building on Windows

    SWIPL_INSTALL_CMAKE_CONFIG_DIR when building for Windows

  • ADDED: var_property/2: singleton property

  • FIXED: PL_assert(): uninitialized var. Joost Geurts

  • BUILD: Fixed dependency problem, often showing up as below, but
    depending on the timing other errors are possible. ERROR:
    source_sink `library(swi_hooks)’ does not exist

  • ADDED: PL_assert(). Suggested by Barry Evans.

  • CLEANUP: Put exports of pl-comp.c in new pl-comp.h

  • ADDED: CMake export config to SWIPL install. This adds files in
    lib/cmake/swipl which can be used by CMake in an external project to
    automatically find the swipl program or library as needed, including
    dependencies such as include paths.

  • FIXED: Atom garbage collection marking issue using copy_term/2 and
    friends together with stack freezing. This notably happens with
    nb_setarg/3 and exception handling. Diagnosed and fixed by Keri

  • PORT: deal with mmap without MAP_ANONYMOUS or MAP_ANON. This assumes
    such systems do an anonymous map if fd is -1.

Package bench

  • BUILD: Make benchmarks work without autoloading.

Package cpp

  • CLEANUP: MSVC no longer thinks throw doesn’t return

Package jpl

  • ENHANCED: documentation on developing JPL

Package ssl

  • CLEANUP: Avoid two “return makes pointer from integer” warnings.

Does this apply to SWISH?

Yes. The main SWISH site was updated soon after this was found.

1 Like

Disclaimer: I always get the freshest bugs from everywhere.

At the moment:

$ gcc --version
gcc (GCC) 10.1.0

Maybe somehow related to the compiler and commit 2d6fa8902f8ae4f00dfddde5b6d3198ba19fd099

[814/2389] Generating ../home/boot.prc
FAILED: home/boot.prc 
cd /home/boris/install/swipl-devel/build/src && /usr/bin/cmake -E remove -f /home/boris/install/swipl-devel/build/home/boot.prc && /home/boris/install/swipl-devel/build/src/swipl -q -O -o /home/boris/install/swipl-devel/build/home/boot.prc -b /home/boris/install/swipl-devel/build/home/boot/
[FATAL ERROR: at Wed May 20 05:37:38 2020
	WAM Table mismatch: wam_table[102(s_static)] == wam_table[103(s_dynamic)]

Probably also because of GCC (they added fancy new warning apparently), I get a whole bunch of warnings. Most look like this:

[251/2389] Building C object src/CMakeFiles/libswipl.dir/pl-tabling.c.o
../src/pl-tabling.c: In function ‘pl_tbl_free_component1_va’:
../src/pl-tabling.c:4588:7: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 4588 |       free_component(c, FC_DESTROY);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is there anything I can do to help troubleshoot this?

1 Like

FWIW, I have the following and I get a clean build + test. If you can suggest how to get a newer gcc, I can try that (I’m just using whatever came with Ubuntu 18.04).

$ git log -n 1
commit 4b561ffca8d4528cfbc7eb17547d1c0db0cd8ccd (HEAD -> master, tag: V8.1.32, origin/master, origin/HEAD)
Author: Jan Wielemaker <>
Date:   Tue May 19 17:00:53 2020 +0200

    Preparing version 8.1.32

$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

$ clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Maybe install Archlinux in a VM? You always get the newest fanciest stuff then :slight_smile: Maybe a docker image would be enough? I haven’t tried it.

I don’t think it is worth it, even it is just for testing.

Commit 2d6fa89 introduced the error (I reproduced it with gcc 10.1), but Jan probably knows that without even looking :slight_smile:

The following should fix the compile failure:

diff --git a/src/pl-vmi.c b/src/pl-vmi.c
index 459f5a84d..104e5af4c 100644
--- a/src/pl-vmi.c
+++ b/src/pl-vmi.c
@@ -2768,7 +2768,9 @@ code.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 VMI(S_DYNAMIC, 0, 0, ())
-{ enterDefinition(DEF);
+  enterDefinition(DEF);


The reason for the failure is that recent versions of GCC merge similar VMI into single jumptable address locations. This can cause problems. For example, without the WAM table consistency check, swipl compiles but fails to run as it mixes up S_STATIC and S_DYNAMIC VMI calls:

[ 64%] Generating ../home/boot.prc

SWI-Prolog [thread 1 (main) at Wed May 20 06:34:24 2020]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
  [0] save_backtrace() at swipl-devel/src/os/pl-cstack.c:332 [0x7f345607ac49]
  [1] print_c_backtrace() at swipl-devel/src/os/pl-cstack.c:867 [0x7f345607aecc]
  [2] sigCrashHandler() at swipl-devel/src/os/pl-cstack.c:905 [0x7f345607b006]
  [3] dispatch_signal() at swipl-devel/src/pl-setup.c:545 [0x7f34560015dd]
  [4] killpg() at ??:? [0x7f3455db7770]
  [5] lookupHTable__LD() at swipl-devel/src/os/pl-table.c:517 [0x7f345606cd18]
  [6] replacedBreakUnlocked() at swipl-devel/src/pl-comp.c:7215 [0x7f3455fb8fee]
  [7] replacedBreak() at swipl-devel/src/pl-comp.c:7232 [0x7f3455fb9910]
  [8] argKey() at swipl-devel/src/pl-comp.c:4291 [0x7f3455fbf421]
  [9] newClauseRef() at swipl-devel/src/pl-proc.c:1093 [0x7f3455fe6c42]
  [10] assert_term() at swipl-devel/src/pl-comp.c:3803 [0x7f3455fbe68a]
  [11] addClauseWic() at swipl-devel/src/pl-wic.c:2868 [0x7f345600e6b0]
  [12] compileFileList() at swipl-devel/src/pl-wic.c:4087 [0x7f34560123e0]
  [13] PL_initialise() at swipl-devel/src/pl-init.c:1051 [0x7f345602b31c]
  [14] ./swipl(+0x10a7) [0x55981e7070a7]
  [15] __libc_start_main() at ??:? [0x7f3455da2ccb]
  [16] ./swipl(+0x10fa) [0x55981e7070fa]

Thanks. Pushed a fix for that.

Hmmm. That looks like a step back for gcc. get_scc() always sets c if it returns non-zero, so this is false alarm. Recent C compilers were smart enough to look around in local (static) functions to figure out these things. One can of course avoid the warning using an explicit initialization, but that comes with two disadvantages: if it is indeed possible that it is uninitialized it is now initialized to some dummy value and the code may misbehave and it inserts a superfluous instruction into the code.

How many of these are there (roughly)?

edit Never mind. Just upgraded to Ubuntu 20.04 which has gcc-10 as an optional package. This reports 28 possibly uninstantiated variables. All tests pass (after the fix above).

Yes, @jan and @keri.harris, the fix is correct. Thank you!

Yes, you probably see the same warnings as me.

One warning is not exactly as all the others, but it still looks like a false positive to me. I will paste it here nevertheless:

[788/2389] Building C object packages/sgml/CMakeFiles/plugin_sgml2pl.dir/catalog.c.o
../packages/sgml/catalog.c: In function ‘find_in_catalogue’:
../packages/sgml/catalog.c:481:30: warning: array subscript -1 is outside array bounds of ‘ichar[8192]’ {aka ‘int[8192]’} [-Warray-bounds]
  101 | #define isDirSep(c) ((c) == '/')
      |                      ~~~      
  481 |  if (p != base && !isDirSep(p[-1]))
../packages/sgml/catalog.c:101:23: note: in definition of macro ‘isDirSep’
  101 | #define isDirSep(c) ((c) == '/')
      |                       ^
../packages/sgml/catalog.c:457:9: note: while referencing ‘base’
  457 |   ichar base[2 * FILENAME_MAX];
      |         ^~~~

Indeed. There is p != base to ensure we do not peek outside the array. I wonder what changed? Compilers cannot 100% accurately figure out all possibilities (this one is really hard). Possibly they changed some rules to avoid missing some real problems, accepting some more false positives?

In this case it seems even hard to come up with something correct that the compiler understands to be correct :frowning:

Being the first time I see you here and seeing all the work you do behind the scenes especially with the garbage collector I just want to say thanks in person.

So Thank You for all your hard work.


I was wrong about that. Keri pointed at a control path returning the value of an external function, so the compiler no longer knows what is going on. The code is correct as this function always returns FALSE, but the compiler only looks at the declaration in the header, so it can’t know.

Now compiles clean on GCC-10. Good thing is that the performance seems about 10% better than GCC-9.3. That is impressive! Most gcc releases resulted in a barely measurable change in performance, showing only some improvements over several years and releases.

Thanks for the input @Boris, @keri.harris


Yes! Compilation time seems to have improved tremendously also!

I still get some swi_hook errors, but it builds fine (the gui works fine too):

$ git describe

$ ninja clean;ninja                                                                                                                                                           10:12:49  ✘ 1 
[0/1] Re-running CMake...
-- Configuring SWI-Prolog-8.1.32
-- Found LibArchive: /usr/lib/ (found version "3.4.3") 
-- Could NOT find Java (missing: Java_JAVAC_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVADOC_EXECUTABLE Java_JAVAH_EXECUTABLE Development) (found version "")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/u/tmp/swipl-devel/build.release
[2/2] Cleaning all built files...
Cleaning... 2436 files.
[94/2389] Checking (git) version
Updated GIT version
[903/2389] Generating pldoc2tex
ERROR: /home/u/tmp/swipl-devel/build.release/home/swipl.rc:207:
ERROR:    /home/u/tmp/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR:    source_sink `library(swi_hooks)' does not exist
ERROR: /home/u/tmp/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR: source_sink `library(pce)' does not exist
[1055/2389] Generating tests/test_certs/generated
ERROR: /home/u/tmp/swipl-devel/build.release/home/swipl.rc:207:
ERROR:    /home/u/tmp/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR:    source_sink `library(swi_hooks)' does not exist
[2389/2389] Generating home/doc/manindex.db

I get the same actually, but since all tests pass and all I do works I have been ignoring those.

I get slightly different errors and warnings. I only see these if I build from the emacs console; when on a regular terminal window, the errors and warnings are over-written (this seems to be a bug in ninja; it shouldn’t be suppressing error messages).

ERROR: /home/peter/src/swipl-devel/build/home/swipl.rc:207:
ERROR:    /home/peter/src/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR:    source_sink `library(swi_hooks)' does not exist
ERROR: /home/peter/src/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR: source_sink `library(pce)' does not exist
[884/2391] Generating ../../home/xpce/man/reference/.created
[885/2391] Building Java objects for jpl_jar.jar
Note: org/jpl7/fli/ uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[951/2391] Building Java objects for jpltest.jar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[1176/2391] Generating tests/test_certs/generated
ERROR: /home/peter/src/swipl-devel/build/home/swipl.rc:207:
ERROR:    /home/peter/src/swipl-devel/packages/xpce/swipl/swipl-rc:135: Initialization goal raised exception:
ERROR:    source_sink `library(swi_hooks)' does not exist

If you use parallel build all depends on timing … Ninja, AFAIK outputs command output if there is output on stderr or the command exit status is non-zero. The nice thing is that it collects the output and ensures it is not interleaved with the output from concurrent commands. You left out the “Generating …” line just above, so I don’t know what the target is that failed. Pushed a fix for the ssl test certificate generation dependencies.

edit Reproduced using a sequential build on Ninja (with error message, also to console). The culprit was pldoc2tex. Added dependency.

I get a clean build now.

Maybe the error messages were being swallowed by ninja because they went to stdout instead of stderr?

Me too. Thanks!