Ann: SWI-Prolog 8.5.9

Dear SWI-Prolog user,

SWI-Prolog 8.5.9 is ready for download. A lot of work has been
done and some regression is not unlikely. Highlights:

  • @peter.ludemann finished the transition of library(pcre)
    (Perl Regular Expressions) to use pcre2. This migration
    became necessary because pcre1 (version 3) is reaching
    end-of-life in many package distributions. Peter not
    only ported the interface to pcre2. He also added a
    lot of functionality and test cases. The interface
    is tested to compile against pcre2 10.31 and 10.37. It
    is not unlikely that compilation and/or tests fail against
    some versions of pcre2.

    Thanks for all the work, Peter!

  • On request from @mgodan1 the C API PL_cleanup() now works
    in the sense that you can re-initialize Prolog after a
    call to this function in the same process. That works
    for the basic Prolog engine and some of the packages.
    Other package may refuse to (re-)start and/or leak
    (a lot of) memory. As a side-effect of this all code
    was extensively executed under AddressSanitizer, gcc/clang
    instrumentation for finding memory issues and leaks. That
    has resolved many leaks during full shutdown, but also
    several ones related in particular to temporary modules
    and message queues when destroyed while not empty.
    SWISH now leaks a lot less memory! AddressSanitizer also
    found 3 buffer overflows by one byte in xpce. Matthias
    contributed several patches to cleanup compilation under MSYS2.

    It is not impossible that these changes have caused some

  • Sockets that have not been closed are now closed by the
    (atom-) garbage collector after the handle becomes unreachable.

  • The Docker for building SWI-Prolog for Windows has been
    updated to be based on Fedora 35 (was 32). This updates
    the MinGW compiler from 9.2 to 11.2 and updates the

  • The UDP socket predicates have some options that simplify
    exchanging messages as UTF-8 and/or as Prolog terms.

Please test and report issues.

edit Make sure to have the pcre2 dependency installed when building from source. On Debian based Linux systems this is in the package libpcre2-dev. On MacOS it is both for Macports and homebrew called pcre2. If you do an incremental build, run cmake -U 'PCRE*' . in the build directory to force rediscovery of all PCRE configuration.

Enjoy --- Jan

SWI-Prolog Changelog since version 8.5.8

  • SNAP: Updated snap package dependency for pcre2

  • FIXED: swipl-ld: access to uninitialized memory

  • FIXED: round/1 near +/- max integer.

  • DOC: complete library index, move gensym and www_browser library docs
    from LaTeX to PlDoc

  • FIXED: round/1 function. As discussed on Discourse. Rick Workman.

  • FIXED: Empty thread queues before deleting them.

  • FIXED: Reclaim stored exception when deallocating a stream.

  • FIXED: Avoid crash updating the stream admin from blob release handlers
    during shutdown.

  • MODIFIED: Added flags and more return values to PL_cleanup().

  • FIXED: abolish/1 on an imported predicate should decrement the
    reference count for the imported predicate.

  • DEBUG: Tricks for ASAN to find the predicates that have not been

  • FIXED: current_predicate/1 bug in updating module reference count
    that may cause temporary modules not to be destroyed. Notably affects

  • DEBUG: Allow for the environment ASAN_OPTIONS=detect_leaks=1 when
    build with ASAN to debug memory leaks and avoid unloading foreign
    libraries using dlclose().

  • DOC: Add transpose/2 to the clpfd docs.

  • FIXED: Allow using delimited continuations after cleanup/initialise

  • FIXED: Cleanup cache for tabling ret/N functors

  • FIXED: Using date and time functions after PL_cleanup().

  • CLEANUP: Silence several warnings on systems that remove assert()

  • FIXED: bulk mode for transactions was not actually passed.

  • PORT: fixed support for systems that lack file mapping

  • FIXED: Single threaded build.

  • FIXED: Issue#961: crash in halt after using the graphical debugger,

  • TEST: Do not load xpce into the basic test suite.

  • DOC: PL_cleanup() docs updated for improved functionality.

  • TEST: Avoid relying on the cat program.

  • FIXED: Memory leak reconsulting a file for deleted predicates.

  • FIXED: retract in nested transaction of a clause asserted in the
    outer transaction to properly reclaim the clause.

  • TEST: Avoid deprecated thread_exit/1.

  • FIXED: Cleaning up locale reference counting and deletion. Could leak

  • TEST: Close the temporary toplevel streams

  • MODIFIED: set_prolog_IO/3 no longer creates a clone stream if stdout
    and stderr are the same stream, but creates an error stream that
    writes to the output (and flushes it). This way we can safely close

  • FIXED: fast_term_serialized/2: memory leak.

  • FIXED: Avoid transaction rollback to be recorded (memory leak).

  • FIXED: Ensure deleting table enum object (leaks).

  • FIXED: Avoid leaking a trie node on concurrent insert of the same

  • ENHANCED: if we created a supervisor that is equal to the existing,
    discard the new one. This may happen if multiple threads create
    a supervisor. Leaks memory as we cannot safely discard a running

  • FIXED: memory leak recliming the IDG for monotonic tabling.

  • FIXED: memory leak on prolog_unlisten/2.

  • FIXED: consistent use of tree pool allocation.

  • TEST: Disable some tests under ASAN as they run out of stack.

  • FIXED: Reclaim indexes array on reclaiming predicates.

  • FIXED: Initial atom table was allocated twice. Also set the initial
    size for this table to be big enough to load the initial state,
    avoiding two rehash operations.

  • FIXED: memory leak when destroying a module holding thread-local

  • CLEANUP: Use one function for deallocating predicate definitions

  • FIXED: Reclaim argument admin for destroyed predicates.

  • CLEANUP: Reclaim “dirty table” and “dewam_table”.

  • CLEANUP: Moved globally cached dict functors to GD.

  • CLEANUP: Reserve global vars for predicates used from C to allow

  • FIXED: PL_cleanup(): reset blob admin.

  • FIXED: Typo on, harming operation without xpce.
    Johan Romme.

  • ADDED: Make encoding accessible by name using PL_atom_to_encoding()
    and PL_encoding_to_atom()

  • DOC: tabling po(Compare) argument.

  • FIXED: predicate_property/2 on visible for zero-argument goals
    could raise an exception.

  • DOC: refer to pack debug_adapter in the GNU Emacs Interface page

  • FIXED: dif/2 not firing after unifying with other attributed variables.

  • CLEANUP: replace start/endCritical by proper functions to simplify

Package clib

  • ENHANCED: Close sockets that are reclaimed because their blob is
    being garbage collected.

  • TEST: Basic tests for udp_send/4 and udp_receive/4.

  • ADDED: udp_send/4: as(Type) option.

  • ADDED: udp_receive/4 as(term) to parse the message into a Prolog

  • ADDED: udp_receive/4 and udb_send/4: encoding(Enc) option to affect
    the encoding.

  • CLEANUP: Use new PL_atom_to_encoding() to avoid code duplication.

  • TEST: Disable test killing non-existing process on MacOS. Can deliver
    SIGTERM to Prolog itself when executed concurrently.

Package http

  • REVERT: It is not a good idea to handle file input not as binary.

  • FIXED: HTTP multipart message handling: set encoding for uploading a
    file and ensure that switching to octet restores the binary mode.
    After report by Mike Elston.

  • TEST: Avoid non-termination if there is an error.

  • TEST: Resolve timing issues in

  • FIXED: http_stop_server/2 to avoid leaking socket handles for
    connections accepted during shutdown.

Package pcre

  • PORT: Make compiled and test using pcre2 10.31.

  • PORT: Make work on systems that do not provide JIT support.
    Possibly it is better to fail on the option in that case?

  • ENHANCED: use pcre2 library instead of pcre1 - Issue #2 - Numerous
    small bug fixes and enhancements (e.g., handling of duplicate
    options, capture_type, error checking). - This commit takes
    advantage of refactoring that was done on the pcre1 code to make
    it easier to handle the pcre2 options (which are both more numerous
    and have a different underlying API). - Added new pcre2 options -
    Removed some obsolete options, preserving backwards compatibility
    where possible - The meaning of optimise(true) has changed - it now
    calls the JIT compiler - Renamed bsr(…) and newline(…) options
    to bsr2(…) and newline2(…) because the pcre2 interface has
    changed - compat(javascript) is replaced by alt_bsux(true) and
    extra_alt_bsux(true) - Code improvements: use uint32_t wherever
    possible instead of unsigned or int - Does not use the new
    pcre2_substitute() for re_replace/{4,5}, re_split/{3,4}, re_foldl/6
    (however, some improvements have been made to the APIs for these). -
    Added test cases

  • FIXED: re_config/2 for jittarget may return a NULL string, crashing
    re_config/2. Mapped to failure.

  • ENHANCED: re_replace/{4,5}, re_split/{3,4} handle capture_type option -
    some refactoring - some bug fixes - added tests

  • FIXED: re_replace/4 can now handle duplicated back references (Issue
    #6) - added escapes for “$” and “” Refactored “capture map” code
    Minor reformatting

  • ENHANCED: re_replace/5 with options list, similar to re_matchsub.
    There are still some “fixme” tests, related to global capture_type.
    Fixed: caching of compiled patterns with options. Renamed some
    predicates to make things clearer.

  • FIXED: re_config/1 throws error for all cases of invalid argument
    Added Unicode tests (for migration to PCRE2 Issue #2) Fixed uncleared
    exception Use convenience function or error returns Regularize some
    names Documentation had “optimize” option; code had “optimise”

    • allow both Fixed detection of type suffix in pattern names Fix
      potential memory leaks and missed error checks Refactor conflated pcre
      return code PL_… return code Document return codes Lower-case cmake
      functions that are lower-case elsewhere Small fixes from turning on
      more compiler warning

Package sgml

  • ENHANCED: Avoid leaking the DTDs in the main thread on exit.

Package ssl

  • ADDED: Implement clean shutdown hook support for HTTPS.

Package xpce

  • CLEANUP: MinGW-11 complains on cl_hash() in gitwrite.c. Code seems
    fine to me, but a simple memset() does the same trick and keeps the
    compiler silent.

  • FIXED: GIF: Write last byte outside mask image if width is divisible
    by 8.

  • FIXED: Buffer overflow by one byte. Avoid using alloca().

  • FIXED: Read outside object.

  • PORT: Avoid non-portable %I64d.

  • TEST: Make test file conform to policies and include into the test set.


Thanks to all those that contributed. :+1:

1 Like