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
documentation
FIXED: Build for Win32: separate VMI for T_TRY_MPZ. Relates to
2d6fa8902f8ae4f00dfddde5b6d3198ba19fd099
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.
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
BUILD: Also define SWIPL_CMAKE_NAMESPACE and
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
Harris.
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.
Harmless.
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?
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 <J.Wielemaker@cs.vu.nl>
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
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
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]
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).
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
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.
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.
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/atom_t.java 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.