# Ann: SWI-Prolog 8.4.2 (stable)

**URL:** <https://swi-prolog.discourse.group/t/ann-swi-prolog-8-4-2-stable/5004>\
**Category:** Releases\
**Created:** [February 10, 2022, 11:45am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-8-4-2-stable/5004 "2022-02-10T11:45:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [February 10, 2022, 11:45am UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-8-4-2-stable/5004/1 "2022-02-10T11:45:40Z")

</div>

Dear SWI-Prolog user,

A new stable version of SWI-Prolog, 8.4.2, is ready for download. This  
backports most changes that have no or defendable compatibilitty impact.  
Most changes address portability issues and a couple of crashes. The  
main incompatible changes are listed below.

- The MacOS SWI-Prolog.app bundle is now a _universal binary_ that runs  
on Intel Macs and M1 (Silicon) Macs. Recent changes for SWI-Prolog.app  
dealing with locale (language) and start directory are included.

- print\_term/1,2 has many enhancements and fixes. Output may thus  
be different.

- The write\_term/3 option `brace_terms` behavior was the inverse  
of the documentation. This is fixed. Code using this feature  
must be updated.

- For foreign code, `qid_t` is now a `void*` rather than `intptr_t`.  
As the have the same width, binaries are compatible. Source code  
using `intptr_t` instead of `qid_t` compiles correctly, but with  
a warning.

- Foreign code using `PL_prof_type_t` may need to be updated for  
changes to this structure. It is unlikely there is any other  
usage for this than xpce.

# SWI-Prolog Changelog since version 8.4.1

- FIXED: Tracer retry on a parent frame. Notably causes problems if  
retrying runs cleanup handlers.

- MODIFIED: MacOS SWI-Prolog.app working directory and locale setup.

- MODIFIED: MacOS `swipl-win` to start in ~/Documents.

- MODIFIED: MacOS: set LC\_CTYPE to UTF-8 if neither LANG nor LC\_CTYPE is  
set. Also set the `encoding` flag to `utf8` if `LC_CTYPE` is set to  
`UTF-8`.

- PORT: Started Apple specific predicates. Adds  
apple\_current\_locale\_identifier/1.

- PORT: Fix compilation using clang in debug mode.

- FIXED: make/0 to consider a file modified if some indirectly included  
file is modified. Used to only consider directly included files.

- FIXED: Possible GC crash on a rational number appearing in a clause  
head.

- FIXED: Indexing issue for assessing possible clauses indexes in SSU  
code. Can lead false “No matching clauses” errors.

- DOC: read\_string/3: clarify _characters_.

- COMPAT: format/2: a numeric argument to `~s`, e.g., `~3s` truncates  
the string to the given number of characters.

- COMPAT: format/2: ~r uses default radix of 8, compatible with SICStus  
and GNU-Prolog (used to raise an exception). Paulo Moura.

- FIXED: `set_prolog_flag(threads, Val)` deadlocked. Paulo Moura.

- FIXED: big integers constants in arithmetic expressions under  
optimization could be compiled as A\_MPQ (rational), resulting in  
a crash. Paulo Moura.

- DOC: further enhancement to untable/1 docs.

- DOC: document the role of untable/1.

- ADDED: foldsubterms/5 and use this to bootstrap foldsubterms/4,  
mapsubterms/3 and mapsubterms\_var/3.

- ENHANCED: print\_term/1,2: actually handle the `left_margin` option  
(fix) and make its default the current column.

- FIXED: print\_term/1,2: avoid dependency on library(backcomp).

- FIXED: call\_residue\_vars/2: if GC performs early reset on an attvar  
it is incorrectly considered residual.

- DOC: Fixed PL\_get\_dict\_key() docs. Matthijs van Otterdijk.

- ENHANCED: Use mallinfo2 when available. By @mgodan1.

- DOC: Fixed error in CMake build script for the manual.

- DOC: Fixed LaTeX errors.

- FIXED: Another postfix operator issue as a regression to recent fixes  
on postfix operator handling. Affects the R interface (reported  
by Nicos Angelopoulos for real, but probably rserve\_client is also  
victim).

- DOC: clarify module issues wrt. macro expansion and explain what is  
affected by import modules.

- DOC: read\_term/2: quasi quotation layout

- TEST: read\_term/2 subterm\_position option. Contributed by Peter  
Ludemann.

- FIXED: Possible crash in copy\_term/4 and copy\_term\_nat/4.

- ADDED: copy\_term/4 and copy\_term\_nat/4. These predicates provide a  
partial renaming of variables and is used in s(CASP). This patch also  
improves out-of-memory handling and adds a test suit for copy\_term.

- PORT: Added missing include for \<errno.h\>

- ADDED: mapsubterms\_var/3 as an alternative to mapsubterms/3 that also  
maps variables.

- ENHANCED: If a package is available both globally and locally (per  
user), ignore the global one silently rather than with a warning.

- ADDED: pack\_install/2: option global(Boolean) to explicitly install  
a package for the user or globally.

- BUILD: Include debug info with PGO build.

- CMAKE: let Threads use -pthread instead of -lpthread This can link  
other needed libraries, and fix building on riscv64.

- FIXED: Avoid warnings about uncaught exceptions from write\_length/3  
in print\_term/2.

- ENHANCED: Edits commit 18690d80fbdc842a5bad3da1fb81a083e55b1b24.  
Forgotten amend and already pushed to origin.

- FIXED: qsave\_program/2: add missing load\_module for shlib The  
predicate current\_foreign\_library is used which is from the module  
shlib. Unfortunately it is not imported though, which makes it  
impossible to use qsave without autoloading enabled.

- TEST: Started a few operator tests

- FIXED: handling postfix operators must reduce the left side before  
reducing the postfix operator.

- ENHANCED: Issue#24: clause\_info/4: reject if term layout returned  
by expand\_term/4 is bogus. This forces the guitracer to revert to  
decompiling.

- FIXED: `arg xf xf` (cascading postfix operators) where the priority  
of the first is higher than the second must generate a syntax error  
rather than an incorrect term.

- DEBUG: Fixed duplicate debug id

- FIXED: print\_term/2 handling of postfix operators.

- SECURITY: running plain `swipl` loads `init.pl` from the current  
directory if this file exists. It is not advised to load customisation  
files from the current directory. We now only load init.pl when  
explicitly called using `swipl -f init.pl` while an implicit init file  
is only loaded from the `user_app_config` path alias.

- DOC: foreach/2 by @swi

- FIXED: SWISH Issue#146: failure to render stacktrace due to failure  
of message\_to\_string/2 on ansi(Style, Fmt, Arg) if Arg is not a list.

- MODIFIED: Query identifiers now keep track of the engine to which they  
are associated. As a result, they are now anonymous pointers rather than  
(pointer wide) integers. Does not affect compatibility except source  
compatibility when the value is combined with integral types.

- BUILD: Disable MQI if multi-threading is not enabled.

- FIXED: print\_term/2 from entering a loop. Also fixes unneeded  
parenthesis in lists.

- FIXED: finding clauses from a source location could crash on thread  
local predicates

- FIXED: print\_term/2: respect write options when computing with of  
native output.

- MODIFIED: print\_term/2 to get the default right margin from tty\_size  
if the output is a tty and tty\_size/2 succeeds.

- FIXED: We must preserve the pack registration when creating a saved  
state to make loading foreign resources work.

- ENHANCED: main/0 to avoid setting up application signal handling and  
termination when run interactively.

- FIXED: Issue#917: separate S\_DYNAMIC and S\_MULTIFILE. Jos de Roo.

- ADDED: print\_term/2: options fullstop(Boolean) and nl(Bool). Also lots  
of documentation restyling and removed old conditional compilation.

- ENHANCED: print\_term/2 to deal with operator expressions that exceed  
the line width.

- FIXED: print\_term/2: max priority of list elements and compound term  
arguments to 999 to force parenthesis.

- FIXED: Issue#917: WAM Table mismatch: wam\_table[119(s\_static)] ==  
wam\_table[124(s\_multifile)]

- FIXED: Ensure VMI instruction are on unique addresses. This patch  
extends 7bf463db4dcc7b4e27c820ef8fc6f94fd8116720 for the case that  
two VMIs jump to the same real implementation.

- PORT: Guarantee two VM instructions are not optimized to use the  
same code.

- FIXED: Ensure bigints are properly indexed on 32-bit platforms.

- PORT: On MacOS fat executables, both try fat-darwin and the actual  
archirecture when searching foreign resources.

- PORT: Set archirecture name of fat packages to `fat`.

- PORT: Support generation of MacOS universal (fat) binaries.  
Also updates minimum supported MacOS version to 10.14.

- PORT: Dynamically determine actual architecture on MacOS

- PORT: Install openssl.cnf with MacOS dependencies  
(scripts/macos-deps.sh)

- PORT: By default disable tcmalloc for MacOS as it causes a crash in  
setlocale() for Monterey.

- ENHANCED: explain/1: hide system references.

- PORT: Building an apple bundle using Qt6

- PORT: Updated script for MacOS dependencies

- DOC: return type for PL\_put\_variable(), PL\_put\_bool() and PL\_put\_atom()  
is `int`.

- FIXED: Handle new terminal hyperlink elements in message\_to\_string/2

- PORT: MacOS to deal with installation directory for libjpeg as  
installed by Macports. This patch also disables more Macports and  
Homebrew locations if we provide our own dependencies.

- BUILD: By default use Macports gcc11 (gcc-mp-11)

- EHNANCED: SICStus datime/2 emulation now supports mode datime(-When,  
+Datime).

- ADDED: random\_subseq/3 and random\_numlist/4 to  
library(random). Compatible with SICStus.

- PORT: Fixed cmake issue for MacOS Homebrew dependencies.

- DOC: edit/0.

- FIXED: thread\_update/2 when no change is made to the target module  
should still wakeup.

- ADDED: prolog\_choice\_attribute/3: `clause` attribute to find the next  
candidate clause.

- FIXED: Initial value for the Prolog flat `on_warning` must be `print`.

- FIXED: Stack trace line-level location when parenthesis are used.

- MODIFIED: write\_term/3 option `brace_terms` behavior was the inverse  
of the documentation. As the docs describe what one would expect and  
is consistent with YAP, the implementation is fixed. We do not expect  
this option to be frequently used. Code using `brace_terms(true)` must  
be updated to use `brace_terms(false)`. If you need to do a runtime  
check to beor conditional compilation compatible with older versions,  
one can use this condition to verify the correct new behavior.

- FIXED: Missing import into library(listing).

- ADDED: write\_term/2: option `quote_non_ascii`. This option is enabled  
by default for write\_canonical/1.

- ADDED: PL\_write\_term(): `PL_WRT_QUOTE_NON_ASCII` flag

- FIXED: write\_canonical/1 to use the `brace_terms` option as `false`.

- FIXED: Make write/1 and friends escape characters that the stream  
cannot represent.

- FIXED: write/1 and friends: we must check that the first character  
can be represented by the stream.

- ADDED: Server socket support to SICStus 4 library(sockets) emulation.

- FIXED: If we abort in the tracer from a redo port that is on a foreign  
predicate we must discard this (foreign) frame.

- PORT: First attempt to support MacOs M1 with brew deps in /opt/homebrew

- ENHANCED: Base clause indexing hash for indirect types (strings,  
bigints and rationals on the start, end and length if the size exceeds  
4 machine words. Without, the time to compute the hash easily becomes  
dominant. Found by Rick Workman.

- REFACTOR: Get all index key computation in one place.

- BUILD: Provide more control over the PGO build.

- ADDED: argv\_options/3 to process type `number`

- FIXED: profile/1 involving code executed in a temporary module.

- MODIFIED: This patch modifies `PL_prof_type_t`, the interface to  
extend the SWI-Prolog profiler. Foreign code using this may need to  
be updated. Most likely only used by xpce.

- FIXED: dif/2: we should ignore unrelated attributes.

- FIXED: Issue#907: failure to fully reclaim clause indexes under  
some loads.

- CMAKE: Support older CMake versions.

## Package bench

- BUILD: Fixed running the benchmarks if GMP is not provided (perfect.pl  
causes an integer overflow).

- ENHANCED: Allow deleting the files for certain benchmarks and  
automatically skip these.

## Package clib

- ENHANCED: Use mallinfo2() when available. By @mgodan1.

- FIXED: #pragma inside an if () else goes wrong on gcc.

- PORT: Silence deprecated vfork() message.

- SANDBOX: Declare part of the SHA predicates sandbox safe.

## Package http

- ENHANCED: verify server address when starting an HTTP server and  
raise an error if this is invalid.

- FIXED: Handle ansi(Style, Fmt, Args), url(Pos) and url(URL, Label)  
message line elements when formulating an HTTP response.

- ADDED: Handle new console hyperlink message line items when converting  
error messages to plain text.

- TEST: More debug messages for test\_proxy.pl and avoid reporting  
expected errors.

- FIXED: javascript quasi quotation for regex objects holding  
backslashes.

- TEST: Simplified shutdown management for the http:proxy tests.

## Package jpl

- CLEANUP: Type correctness in debug messages.

- COMPAT: Allow qid\_t to be an opaque pointer.

- TEST: Disable prolog-in-java test if hamcrest-core is not found  
(broken on Macports)

## Package mqi

- FIXED: Fix bug in docs that used old (invalid) parameters to Python  
function

- FIXED: Updated Python library on [pypy.org](http://pypy.org) to match this version  
[Client Challenge](https://pypi.org/project/swiplserver/1.0.2/)

- FIXED: Hang with multi-byte UTF8 characters reported by @Losbarthos  
Details in: [Problem with unicode characters (e.g. →) in prolog file · Issue #14 · SWI-Prolog/packages-mqi · GitHub](https://github.com/SWI-Prolog/packages-mqi/issues/14)

- ADDED: A simple protocol versioning interface to the MQI. There is  
now a mqi\_version/2 predicate and the MQI returns Major and Minor version  
in its response to an initial connect message.

- ADDED: The swiplserver Python library properly detects the original  
and fixed versions and works against both of them.

- TEST: Added tests for multi-byte UTF8 characters

- TEST: Do not run tests if we do not have Python3.

- ADDED: Created Python swiplserver 1.0.1 on [pypi.org](http://pypi.org)  
([Client Challenge](https://pypi.org/project/swiplserver/1.0.1/)) to include fixed file  
handle leak

## Package nlp

- MODIFIED: Tokenize +digits as `[+, int]`. This is consistent with  
read/1 parsing `+42` into `+(42)`.

## Package pengines

- FIXED: Pengine emulation of tab/1 to accept an expression.

- ADDED: Deal with new url message line element.

- ADDED: handle full\_stop(Bool) and nl(Bool) in translating Prolog  
terms to HTML.

## Package plunit

- FIXED: Allow include/1 to include tests between begin\_tests/1 and  
end\_tests/1. This patch is incomplete because failing tests are  
reported with the source line of he included file but the file name  
of the main file.

## Package protobufs

- BUILD: Silence message about enabling tests. We want the cmake run  
as quiet as possible.

## Package readline

- PORT: allow readline to be installed in /opt/homebrew/
- PORT: (MacOS M1 with homebrew) allow readline to be installed in  
/opt/homebrew/

## Package semweb

- FIXED: term\_expansion/2 for rdf\_meta/1 contained a !, preventing  
other rules to fire.

- ADDED: rdf\_meta/1: apply conversion in SSU heads.

- FIXED: rdf\_global\_term/2: Allow for zero-arity compounds.

- COMPAT: do not require white space after the subject and predicate  
of ntriple format.

## Package sgml

- ENHANCED: xsdp\_subtype\_of/2 to be fully logical. Wouter Beek.

## Package ssl

- PORT: `error: ‘rsa’ undeclared` for old OpenSSL and LibreSSL.

- PORT: Make the package use the OpenSSL 3.0 API rather than  
the deprecated 1.1 API when compiled against OpenSSL 3. Patches  
521519daa44b48efa0292cf0d29d741347b8c1bf..ac018967bfdeb4d534a247f879909c6d4a4e3199  
Contributed by Matt Lilley.

- PORT: Silence SecKeyChainOPen deprecation for MacOS.

- PORT: Fix build on OpenBSD 7.0 using LibreSSL LibreSSL 3.4.0 made  
struct ssl\_session\_st opaque.

## Package swipl-win

- CLEANUP: Avoid messagebox when terminating.

- PORT: Demand Qt 5.15 or 6.

- FIXED: Simplied exit menu, working again, fixed QVariant type()  
usage warnings

## Package xpce

- FIXED: Issue#10 for swipl-win: `display->confirm` hides message  
box in the background.

- FIXED: Issue#14 (swipl-win, should be xpce)  
`emacs_frame->on_current_desktop` failed if the frame is  
iconized. This keeps creating new frames rather than reusing them.

- FIXED: frame-\>expose for Windows when xpce is running in the  
background.

- CLEANUP: workaround to suppress a false positive warning from gcc-11  
and avoid a pragma at the same time

- FIXED: Transfer selection from xpce as UTF-8 when requested using a  
media type (`text/plain;charset=utf-8`).

- FIXED: Handle new message elements for generating feedback in PceEmacs.

- FIXED: pceemacs\_client.pl for MacOS

- FIXED: GUI tracer: avoid instantiation error. Kwon-Young Choi.

- FIXED: Allow the Prolog Navigator to work with zero-arity compounds.

- ENHANCED: Avoid check/0 to report autoload/2 to be redefined.

- ADDED: pceemacs\_client.pl, replacing edit.sh and client.c.
