Ann: SWI-Prolog 9.3.33

Dear SWI-Prolog user,

SWI-Prolog 9.3.33 is ready for download. Important updates

  • Many updates to the development environment.
    See Package xpce below. Most importantly:
    • Fix two critical memory management issues in the new
      swipl-win console.
    • Fixed a couple of ANSI escape sequence implementations,
      notably fixing insert in the command line editor on some
      platforms.
    • Added a Debug menu to the swipl-win console.
    • The special-purpose allocator of xpce has been replaced
      by standard malloc() and friends. The development
      environment has been used for almost a week using
      AddressSanitizer. This fixed several use-after-free
      issues. These were harmless with xpce’s allocator and
      no multi-thread support. Now they are more critical.
    • Fixed three threading issues in xpce after reports by
      @mike.elston.
  • Moved JSON libraries from the http package to a new json
    package. This moves e.g. library(http/json) to
    library(json). The old library is still there, loading
    the new library and printing a message.
  • Added Ubuntu PPA for 25.10 (Questing Quokka)

Current development releases primarily prepare for the next stable
release.

Enjoy --- Jan

SWI-Prolog Changelog since version 9.3.32

  • PPA: Added Ubuntu 25.10 (Questing Quokka)

  • FIXED: Install of non-qlf json compatibility wrappers.

  • ADDED: packages/json

  • ADDED: call_in_thread/3. Extends call_in_thread/2 with options.

  • DOC: term_size/2: cells are always 8 bit in recent versions.

  • ENHANCED: Messages for managing spy points.

  • ENHANCED: listing/0,1,2 to respect the terminal width. If the output
    is a terminal, tty_size/2 is used to determine the line width.

  • DOC: test_installation/0: document permission requirements on the
    working directory.

Package clib

  • DOC: Document some types for lirary(uri).

Package http

  • PACKAGE: Remove JSON files from this package The JSON support is
    moved into a new package json

  • ADDED: Support HttpOnly and Secure cookie properties
    in http_session.pl http_set_session_options/1 now supports the
    http_only(true) and secure(true) options, adding these properties to
    the session cookie. Both default to false for compatibility reasons.

    Suggested by Mohammed Almutawah to mitigate XSS scripting in SWISH.

Package libedit

  • ENHANCED: Support thread signal processing while reading from
    Epilog. This is required to prevent the Debug menu of Epilog
    from deadlocking the application. It also allows e.g., timers to
    function in Epilog consoles. Note that signal processing already
    worked in non-Windows environments.

  • ADDED: el_version/1 to get the version of the editline library used.

Package xpce

  • FIXED: Use-after-free graphical->unlink destroys its
    <-layout_interface, i.e., the table_cell. Using a code reference
    delays the actual deallocation.

  • ENHANCED: Avoid deadlocking Epilog if thread is not sensitive to
    signals.

  • MODIFIED: Windows: open Epilog pipe in client using
    FILE_FLAG_OVERLAPPED This patch must be combined with updating the
    libedit package.

  • FIXED: Thread-safety for passing raw Prolog terms through xpce

  • FIXED: Erroneous transfer for xpce references.

  • FIXED: Allow frame->wait to be called from any thread.

  • FIXED: Make the AnswerStack thread local.

  • FIXED: Invalidate source location cache after reloading a file.
    Broken after introduction of atomic reconsult that preserves clauses
    as much as possible.

  • FIXED: Memory management for frame<-confirm and friends.

  • ADDED: GUI Tracer to show details and copy constraints Cycles and
    constraints displayed in the Bindings sub-window now support the
    Details and Copy functionality.

  • ENHANCED: do not trace switching the GUI tracer on/off.

  • ADDED: Epilog: Debug menu.

  • ENHANCED: Epilog message capturing. swipl-win: make sure all
    messages printed to the main thread end up in an Epilog window.

  • FIXED: Possible use-after-free

  • FIXED: Possible use-after-free

  • FIXED: Read beyond the end of local array. May lead to invalid UTF-8
    sequences and corrupted terminal output.

  • FIXED: Possible memory corruption.

  • FIXED: Epilog: correctly handle \e[@. This escape sequence is
    used for inserting into the commandline. Its default should be 1 rather
    than 0. This fixes inserting into the commandline, notably on Windows.

  • FIXED: Various encoding issues in class file.

1 Like

Hi

PceEmacs does a great job of highlighting potential errors including undefined and unused predicates but there seems to be an asymmetry when it comes to meta predicates. PceEmacs is aware of meta_predicate declarations and correctly highlights in red undefined predicates in the calling context but always shows the called predicate definition in red.

Example 1

t :-
  foo(bar).   % bar is black - good!

:- meta_predicate(foo(0)).

foo(Goal) :-
   call(Goal).

bar.       % bar is red even though it is called from foo/1 and PceEmacs knows its called

Example 2

t :-
   foo(xbar).   % xbar is red - good!

:- meta_predicate(foo(0)).

foo(Goal) :-
   call(Goal).

bar.       % bar is red which is correct in this case

The problem is that, according to the de-facto standard, the meta_predicate/1 declaration should be visible before any calls to the predicate. In most systems, this causes the compiler to turn t/1 into

t :-
  foo(user:bar).

SWI-Prolog’s handling of meta predicates works a little different, so the code runs fine regardless of the location of the declarations. The cross-referencer is a one-pass analysis though. When it seens foo(bar), it has not yet seen the meta_predicate/1 call and considers bar just data. You can see the difference. If you move the meta_predicate/1 declaration to the top of the file, the highlighting is correct and bar has a context menu that allows jumping to and getting info on bar/0.

So, it is good practice to put meta_predicate/1 declarations near the top of the file. Note that for exported predicates they must appear before the first non-directive. This because the cross referencer examines a not-loaded module by parsing the file up to the first non-directive. It uses that to extract exported predicates and their (meta) properties.

Should be something for a linter :slight_smile: Maybe we can extend the cross-referencer to emit a warning if it found calls to a predicate before its meta-predicate declaration?

Thanks Jan. Moving meta_predictate declarations near the top of the file is no hardship but yes it would be nice indeed one day for the cross-referencer to emit a warning if it found calls to a predicate before its meta-predicate declaration.