# Ann: SWI-Prolog 9.3.8

**URL:** <https://swi-prolog.discourse.group/t/ann-swi-prolog-9-3-8/7588>\
**Category:** Releases\
**Created:** [July 10, 2024, 7:01pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-3-8/7588 "2024-07-10T19:01:09Z")\
**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:** [July 10, 2024, 7:01pm UTC](https://swi-prolog.discourse.group/t/ann-swi-prolog-9-3-8/7588/1 "2024-07-10T19:01:09Z")

</div>

Dear SWI-Prolog user,

SWI-Prolog 9.3.8 is ready for download. It comes with a lot of  
changes, many of which are internal. Visible changes are notably to  
the C/C++ interfaces. Hoghlights:

- Introduced PL\_free\_term\_ref() to simplify dealing with temporary  
term references that build up inside a loop. @peter.ludeman added  
support for this to C++ using PlTermScoped.

- The C API now validates the validity of `term_t` handles. This  
should make the development of C/C++ extensions a more robust  
process as it will capture the vast majority of illegal use of  
term\_t handles we see in the wild.

- Some small performance improvements, preparing for more.

- Better handling of crashes when running unattended: better  
crash reports and better guarantee that the process won’t  
deadlock during the crash reporting.

- Better handling of the `xterm` interface that allows creating  
multiple consoles from the same process on X11 systems.

- A start for supporting [htmx](https://htmx.org)

- Better throughput of multiple ouput messages from Pengines over  
HTTP.

- The Python interface now supports py\_string\_as(codes) (or chars)  
to get Python strings as a Prolog list.

- Many portability issues and fixes for `-fsanitize=undefined`  
with input from @mgondan

# SWI-Prolog Changelog since version 9.3.7

- FIXED: Type for PL\_get\_intptr\_ex(). Breaks on Win32

- CLEANUP: Make all code clean for clang-18 -fsanitize=undefined

- ENHANCED: Added ‘c\_cxx’ flag and env SWIPL\_CXX for packs

- FIXED: #1292: possible stack corruption in exception handling.  
Probably can only be triggered if `SECURE_GC` is enabled which wipes  
the unused parts of the stacks in trimStacks().

- SANDBOX: Allow for term\_singletons/2

- FIXED: #1292 Possible stack corruption after exception.

- FIXED: unification of zero-arity compounds

- FIXED: Possible assertion error due to unify refactoring.

- FIXED: thread\_signal/2: may raise exception and succeed.

- CLEANUP: Refactor unify() Split into a function that deals with  
everything except compounds and one that does the whole thing.  
This makes the function a lot easier to understand. This rewrite  
has no measurable performance implication and should make it a bit  
easier to optimize it further.

- ENHANCED: Simplify H\_VAR

- ENHANCED: Low-level unification to constants Speeds up unification  
from foreign code to atoms and small integers.

- ENHANCED: make/0: no longer try to update the indices of system  
libraries. These libraries are properly maintained by the build and  
installation process while the time stamps are often wrong after the  
installation process.

- FIXED: Do not wait longer than 30 seconds after a crash. This deals  
with situations where error reporting and cleanup hangs due to  
a deadlock.

- DOC: time/1: we do support per thread CPU time on MacOS.

- FIXED: Properly export `environment_frame` in foreign predicate redo.  
The incorrect setting causes problems in the new consistency checks  
for `term_t` as well as confusing backtraces.

- PORT: Possibly collapsing VM instructions on 64 bit Visible using  
gcc 14 on arm64 (Asahi Linux)

- WASM: `SWIPL()` initialization changed in Emscripten Where  
`SWIPL(Module)` used to return a Promise that would complete  
returning the same `Module`, it now returns a new module object  
that is independent from the agument passed.

- ADDED: PL\_free\_term\_ref() In addition, this patch distinguishes  
term\_t originating from predicate arguments (which cannot be freed  
and to which we cannot “write” (PL\_put\_\*())) from user allocated  
term references.

- ADDED: Validate arguments to the C API PL\__() functions. This commit  
validates term\_t, atom\_t and functor\_t parameters to the PL\__()  
functions that terminates the process if it finds invalid data.

- ADDED: PL\_api\_error() to signal invalid use of the API

- FIXED: =@=/2: attributed variables must be handled as normal variables.

- FIXED: Determine file exports under conditional conditional  
compilation.

- FIXED: Process multiple predicates from export/1 directives.  
To determine file exports, we considered only a single predicate  
for export/1.

- FIXED: Stops repeated crash reports While recursive crashes where  
dedected, no appropriate action was taken, leading to endless error  
reports.

- FIXED: ‘$open\_xterm’/5: raise exeption if we cannot run xterm.  
Used to hang, waiting for output from the xterm process.

- MODIFIED: Renamed `open_xterm/5` as private `'$open_xterm'/5`.  
open\_xterm/5 was not documented. This patch removes the implementation  
completely if the OS lacks the required POSIX pty support and renames  
the predicate to `'$open_xterm'/5` if xterm consoles can be supported.  
In addition, this patch adds conditional compilation to console support  
in `library(threadutil)` if neither the Windows support nor the xterm  
support can be provided.

- FIXED: Build dependency of documentation on `utf8proc` package

## Package cpp

- ENHANCED: Use read mutex for AtomMap::find()

- ENHANCED: added move constructor to PlRecord to support make\_pair()

- FIXED: base class visibility

- DOC: fix some obsolete function names

- ENHANCED: convenience methods in PlRecordExternalCopy

- ENHANCED: Experimental PlTermScoped API

- DOC: PlTail is now PlTerm\_tail + fix examples

- PORT: OpenBSD does not have malloc header

## Package http

- ADDED: library(http/htmx). Support predicates for [htmx.org](http://htmx.org)

## Package jpl

- TEST: removed Garbo.java This file uses the deprecated `finalize()`  
method and does not seem to be used anywhere.

- TEST: Find hamcrest needed for JPL tests on Fedora

- FIXED: Illegal use of SWI-Prolog API Code as modifying predicate  
arguments.

## Package ltx2htm

- FIXED: Avoid overwriting predicate argument

## Package pengines

- ADDED: Add support for put\_code/1 and put\_char/1 to  
library(pengines\_io)

- CLEANUP: Use reply\_json\_dict/1 for replying

- ADDED: Add support to collate multiple output events. This extends  
the HTTP protocol to wait for more output, sending multiple output  
events as one chunk. The chunk is ended if no more output is timely  
available, the max of (currently 100) output events is collected,  
or a non-output event is found.

## Package plunit

- FIXED: run\_tests/0-2: correctly report combined CPU usage.

## Package protobufs

- CLEANUP: tests now run outside the build

- TEST: Use cmake’s built swipl executable where possible

- DOC: examples+tests using updated protobuf-compiler package

## Package sgml

- FIXED: Avoid referencig an invalid term\_t

## Package ssl

- FIXED: Illegal use of SWI-Prolog API

## Package swipl-win

- PORT: Require C+±17 (was C+±11)

## Package swipy

- FIXED: accept string(Text) as input Added tests for extended  
py\_string\_as().

- ADDED: support for py\_string\_as() option with `codes` or `chars`

## Package xpce

- CLEANUP: Use offsetof() where applicable This avoids runtime errors  
when using `-fsanitize=address`
