Ann: SWI-Prolog 9.3.34

Dear SWI-Prolog user,

Version 9.3.34 is ready for download. Almost all changes are bugfixes
and enhancements to the development environment and tools. Notably

  • Commandline history handling is simplified a lot by removing a
    lot of old code and building on top of the enhanced libedit
    extension. Notably, reusing command using !!, !<num>,
    etc is now enabled by default.

  • Epilog now uses the native OS file dialog to ask for files to
    consult, edit or create.

  • Epilog now binds opening a link to Ctrl-click.

  • Breakpoint feedback has been fixed.

  • Fixed memory issue and multi-thread access to xpce (thanks to
    @mike.elston).

    Enjoy — Jan

SWI-Prolog Changelog since version 9.3.33

  • MODIFIED: Use bool types for profiling API Should have low impact.
    Used by xpce.

  • FIXED: Disable Epilog if threads in single threaded version.

  • MODIFIED: halt/1: forward to main thread. If halt/1 is initiated
    from a thread other than main, main is signalled to terminate
    the process. If the main thread does not do so within the time
    specified by the Prolog flag halt_grace_time (default 1 second),
    the process is forcefully terminated.

  • MODIFIED: Commandline history handling. Comandline history handling
    used a double administration, both saving command as Prolog facts and
    in the commandline editor. Now the commandline editor is in charge.
    Visible changes to the user:

    • If library(editline) is not available, there is no history.
    • Without any settings, the history depth is 100. The fact that
      the history is enabled is shows using numbers in the prompt.
    • Substitution using e.g., !!, !<num>, etc. are always enabled.
    • Setting the Prolog flag history to 0 or false disables the
      history. An integer value sets the depth.
  • COMPAT: Use new prolog:message_action/2

  • ADDED: prolog:message_action/2 hook. This separates side effects on
    messages from printing messages, allowing side effects to take place
    even if an earlier print hook suppresses the message.

  • FIXED: Use library broadcast to tell other components of modified
    break-points.

  • TEST: Do not run the “unprotected” tests if protect_static_code
    is set.

  • FIXED: '$clause_from_source'/4, used for setting break-points.

  • DOC: Do not run test_installation twice

  • ENHANCED: xref_source/2: emit warning on late meta_predicate/1 This
    directive must appear before the predicate is being used (called).

  • PPA: Added Ubuntu 25.10 (Questing Quokka)

Package chr

  • COMPAT: Use new prolog:message_action/2

Package http

  • COMPAT: Use new prolog:message_action/2

Package libedit

  • FIXED: Signal handling Detecting this is the main stdin we are reading
    from failed since we use dup() on the file handles to avoid closing
    them. We now add this fact to the context, initiated before the dup().

  • UPDATED: prolog:history/2 to support new core functionality.

  • ADDED: Extended el_history/2 with more actions. This allows for
    querying individual events, setting the notion of current, and
    searching the history.

  • ENHANCED: Read old swipl-win.exe history data in current version.

  • MODIFIED: el_read_history/2 to raise an error if the history file
    is invalid.

  • PORT: Compile if H_SAVE_FP is lacking

  • ADDED: el_history/2: getsize(-Size) support.

Package pldoc

  • FIXED: Load when threads are disabled.

  • COMPAT: Use new prolog:message_action/2

Package plunit

  • COMPAT: Use new prolog:message_action/2

Package xpce

  • ENHANCED: Start Epilog file dialog in working directory.

  • ENHANCED: Make Quit Prolog the default button for confirming close
    with open windows.

  • ADDED: Allow inspecting the GUI hierarchy from Epilog.

  • ADDED: pce_show_visual_tool/0 to library(man/v_visual). This allows
    showing the GUI inspector stand-alone.

  • FIXED: Block other Prolog threads while a window is being redrawn.
    Modifying graphics while a redraw is in progress may result in
    inconsistent graphics or crashes.

  • FIXED: Thread specific module and context object. These two global
    variables are used in the xpce interface predicates to keep track of
    the context. As xpce allows access from multiple threads they must
    be thread specific.

  • FIXED: Exclude files that require threads for single threaded version.

  • FIXED: Ensure Prolog exceptions are propagated through xpce.

  • FIXED: Epilog: save history in all scenarios This covers closing the
    main window using the menu, window close button, Ctrl-D, Shift-Ctrl-W.

  • ENHANCED: Epilog: use native file dialog

  • ADDED: frame<-open_file and frame<-save_file: use OS dialog
    to prompt for a file. These new methods use SDL3’s interface to file
    dialog windows to ask for a file for reading or writing. Tested to
    work on MacOS, Windows and Fedora using Gnome.

  • ENHANCED: Do not load theme based on display<-theme if a theme was
    already loaded.

  • FIXED: Use-after-free in frame<-confirm Also allows this method to
    run from any thread.

  • ENHANCED: Show fragment icons vertically aligned in the line.

  • COMPAT: Use new prolog:message_action/2

  • FIXED: Show breakpoints in PceEmacs and GUI tracer No longer rely
    on messages. There is a problem with the message system where
    user:message_hook/3 is both used to redirect messages and to act
    on messages. The latter are hooks that fail, the first are hooks
    that succeed. It might be better to have two hooks.

  • FIXED: Possible use-after-free

  • MODIFIED: Epilog terminal to follow links on Ctrl-click Used
    to be simple click. This causes too much unintended actions.
    Using Ctrl-click is consistent with other terminal emulators.

2 Likes

Probably not intended. When I started swipl in a directory that had history already, it started counting at 101

$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.34)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

101 ?-

After a few commands I was at 106; the oldest command I could access was 6:

106 ?- !1.
! No such event
106 ?- !2.
! No such event
106 ?- !3.
! No such event
106 ?- !4.
! No such event
106 ?- !5.
! No such event
106 ?- !6.
use_module(library(dcg/basics)).
true.

I can see how that somehow makes sense, I don’t know if it is the desired behaviour.

Yes :slight_smile: The default history depth is 100. That means that any other command added to the history causes the oldest to be deleted. When saving, it saves all 100 (or as many there are) to a file. Restarting loads these 100 commands and thus the next query is ?- 101.

That is how it works in libedit. The rest is now just some Prolog code around it.

1 Like

Does that mean there is no history on windows?

No. The Windows version comes with library(editline). I had to hack the BSD library a bit. That was done by other people, but those ports relied on a lot of other Unix compatibility libraries. I merely replaced some of the low level I/O routines to call native Windows and hard coded that the use of ANSI escape sequences, which is fine for the Windows native consoles as well as the Epilog Prolog consoles.

That is a large part of the beauty of the current code base: it is pretty much the same on all platforms. Before we had a lot of different setups for the console that all had there own peculiar behaviour. Now both swipl and swipl-win behave pretty much the same on Linux/*BSD, MacOS and Windows.

4 Likes

Hi Jan.
This error :

QLF compile library
ERROR: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
ERROR:    source_sink \`library(pcre)’ does not exist
Warning: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
Warning:    Goal (directive) failed: json_schema:use_module(library(pcre),\[re_match/2\])
root@sd-159644:/usr/local/wasm/swipl-devel/build#  

But :

root@sd-159644:/usr/local/wasm/swipl-devel/build# cd /usr/local/wasm/pcre2-10.42
root@sd-159644:/usr/local/wasm/pcre2-10.42# ls
132html		     config.sub		  libpcre2-posix.a	pcre2.h
aclocal.m4	     configure		  libpcre2-posix.pc	pcre2posix_test.js
ar-lib		     configure.ac	  libpcre2-posix.pc.in	pcre2posix_test.wasm
AUTHORS		     COPYING		  LICENCE		pcre2test.js
build.ninja	     CTestCustom.ctest	  ltmain.sh		pcre2_test.sh
ChangeLog	     CTestTestfile.cmake  m4			pcre2test.wasm
CheckMan	     depcomp		  Makefile.am		perltest.sh
CleanTxt	     Detrail		  Makefile.in		PrepareRelease
cmake		     doc		  missing		README
CMakeCache.txt	     HACKING		  NEWS			RunGrepTest
CMakeFiles	     INSTALL		  NON-AUTOTOOLS-BUILD	RunGrepTest.bat
cmake_install.cmake  install-sh		  pcre2_chartables.c	RunTest
CMakeLists.txt	     libpcre2-16.pc.in	  pcre2-config		RunTest.bat
compile		     libpcre2-32.pc.in	  pcre2-config.in	src
config-cmake.h.in    libpcre2-8.a	  pcre2grep.js		testdata
config.guess	     libpcre2-8.pc	  pcre2_grep_test.sh	test-driver
config.h	     libpcre2-8.pc.in	  pcre2grep.wasm
root@sd-159644:/usr/local/wasm/pcre2-10.42#\`\`\` 

pcre2 is nevertheless installed.. I do not understand.

I have reinstalled
root@sd-159644:/usr/local/wasm/pcre2# ls
132html COPYING LICENCE pcre2posix_test.js
AUTHORS CTestCustom.ctest m4 pcre2posix_test.wasm
autogen.sh CTestTestfile.cmake maint pcre2test.js
BUILD.bazel Detrail Makefile.am pcre2_test.sh
build.ninja doc MODULE.bazel pcre2test.wasm
ChangeLog HACKING NEWS perltest.sh
CheckMan index.md NON-AUTOTOOLS-BUILD PrepareRelease
CleanTxt install_manifest.txt pcre2_chartables.c README
cmake libpcre2-16.pc.in pcre2-config README.md
CMakeCache.txt libpcre2-32.pc.in pcre2-config.in RunGrepTest
CMakeFiles libpcre2-8.a pcre2_fuzzer.dict RunGrepTest.bat
cmake_install.cmake libpcre2-8.pc pcre2_fuzzer.options RunTest
CMakeLists.txt libpcre2-8.pc.in pcre2grep.js RunTest.bat
config-cmake.h.in libpcre2-posix.a pcre2_grep_test.sh src
config.h libpcre2-posix.pc pcre2grep.wasm testdata
configure.ac libpcre2-posix.pc.in pcre2.h WORKSPACE.bazel
root@sd-159644:/usr/local/wasm/pcre2#

But :
ERROR: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
ERROR: source_sink `library(pcre)’ does not exist
Warning: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
Warning: Goal (directive) failed: json_schema:use_module(library(pcre),[re_match/2])
:frowning:

Is the pcre2 library in the path given to -DCMAKE_FIND_ROOT_PATH=<dir>? Does this work

node src/swipl.js
?- use_module(library(pce)).

P.s. Please put code in a block guarded by two ``` lines (or indent the code lines with 4 spaces).

P.s. Pushed a patch to omit installing library(json_schema) if regular expression are not provided.

root@sd-159644:/usr/local/swipl-devel# node src/swipl.js
node:internal/modules/cjs/loader:1404
  throw err;
  ^

Error: Cannot find module '/usr/local/swipl-devel/src/swipl.js'
    at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
    at Function._load (node:internal/modules/cjs/loader:1211:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
    at node:internal/main/run_main_module:36:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v22.16.0
root@sd-159644:/usr/local/swipl-devel# 

I add that I compiled pcre2 following your instructions .

The instructions still look fine. Works for me. You’ll have to work through the details of he messages to see what could be wrong. A good step is running

 cmake .

in the build dir. That re-runs the configuration. Normally that is pretty silent, but it will print the things that went wrong while they can easily be missed during the initial cmake run.

80/81 Test #80: json:json_schema .................***Failed    0.51 sec
ERROR: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
ERROR:    source_sink `library(pcre)' does not exist
Warning: /usr/local/wasm/swipl-devel/build/home/library/ext/json/json_schema.pl:62:
Warning:    Goal (directive) failed: json_schema:use_module(library(pcre),[re_match/2])
Cannot find JSON Schema test data; skipping tests
Warning: [Thread main] Halting with status 1 due to 1 errors and 1 warnings

81/81 Test #81: ssl:ssl ..........................   Passed    6.86 sec

99% tests passed, 1 tests failed out of 81

Total Test time (real) =  84.29 sec

The following tests FAILED:
	 80 - json:json_schema (Failed)
Errors while running CTest
root@sd-159644:/usr/local/wasm/swipl-devel/build# ninja install
[34/35] Install the project...
-- Install configuration: "PGO"
-- Set runtime path of "/root/lib/swipl/bin/x86_64-linux/swipl" to "/root/lib/swipl/lib/x86_64-linux"
-- Set runtime path of "/root/lib/swipl/lib/x86_64-linux/libswipl.so.9.3.34" to "/root/lib/swipl/lib/x86_64-linux"
-- Set runtime path of "/root/lib/swipl/bin/x86_64-linux/swipl-win" to "/root/lib/swipl/lib/x86_64-linux"
-- Set runtime path of "/root/lib/swipl/bin/x86_64-linux/swipl-ld" to "/root/lib/swipl/lib/x86_64-linux"
root@sd-159644:/usr/local/wasm/swipl-devel/build# swipl --version
SWI-Prolog version 9.3.28 for x86_64-linux
root@sd-159644:/usr/local/wasm/swipl-devel/build# 

-- Generating done
-- Build files have been written to: /usr/local/wasm/swipl-devel/build.wasm
root@sd-159644:/usr/local/wasm/swipl-devel/build.wasm# ninja
[590/595] QLF compile library
ERROR: /usr/local/wasm/swipl-devel/build.wasm/home/library/ext/json/json_schema.pl:74:
ERROR:    source_sink `library(http/http_open)' does not exist
Warning: /usr/local/wasm/swipl-devel/build.wasm/home/library/ext/json/json_schema.pl:74:
Warning:    Goal (directive) failed: json_schema:use_module(library(http/http_open),[http_open/3])
[594/595] Linking C executable src/swipl-web.js
compressing package of size 9606302
compressed package into 5040871
compressed in 606 ms
[595/595] Linking C executable src/swipl-bundle.js
root@sd-159644:/usr/local/wasm/swipl-devel/build.wasm# 

Pull the latest version and this should be fixed. When building from git source, please check there are no updates or give the version you try to build.

2 Likes

More building blues.

Building C object packages/xpce/C...es/plugin_pl2xpce.dir/src/txt/terminal.c.
FAILED: [code=1] packages/xpce/CMakeFiles/plugin_pl2xpce.dir/src/txt/terminal.c.o 
/usr/bin/gcc -Dplugin_pl2xpce_EXPORTS -I/Users/booris/install/swipl-devel/build/packages/xpce -I/Users/booris/install/swipl-devel/packages/xpce/src -I/Users/booris/install/swipl-devel/src/os -I/Users/booris/install/swipl-devel/src -isystem /opt/homebrew/Cellar/cairo/1.18.4/include/cairo -isystem /opt/homebrew/Cellar/fontconfig/2.17.1/include -isystem /opt/homebrew/opt/freetype/include/freetype2 -isystem /opt/homebrew/opt/libpng/include/libpng16 -isystem /opt/homebrew/Cellar/libxext/1.3.6/include -isystem /opt/homebrew/Cellar/xorgproto/2024.1/include -isystem /opt/homebrew/Cellar/libxrender/0.9.12/include -isystem /opt/homebrew/Cellar/libx11/1.8.12/include -isystem /opt/homebrew/Cellar/libxcb/1.17.0/include -isystem /opt/homebrew/Cellar/libxau/1.0.12/include -isystem /opt/homebrew/Cellar/libxdmcp/1.1.5/include -isystem /opt/homebrew/Cellar/pixman/0.46.4/include/pixman-1 -isystem /opt/homebrew/Cellar/pango/1.57.0_1/include/pango-1.0 -isystem /opt/homebrew/Cellar/harfbuzz/12.2.0/include/harfbuzz -isystem /opt/homebrew/Cellar/graphite2/1.3.14/include -isystem /opt/homebrew/Cellar/glib/2.86.1/include -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/usr/include/ffi -isystem /opt/homebrew/Cellar/glib/2.86.1/include/glib-2.0 -isystem /opt/homebrew/Cellar/glib/2.86.1/lib/glib-2.0/include -isystem /opt/homebrew/opt/gettext/include -isystem /opt/homebrew/Cellar/pcre2/10.47/include -isystem /opt/homebrew/Cellar/fribidi/1.0.16/include/fribidi -isystem /opt/homebrew/include -isystem /opt/homebrew/opt/libedit/include -isystem /opt/homebrew/opt/zlib/include -isystem /opt/homebrew/opt/ncurses/include -O2 -g -DNDEBUG -std=gnu11 -arch arm64 -fPIC -fvisibility=hidden -Wall -DHAVE_CONFIG_H -DSWI -D__SWI_PROLOG__ -MD -MT packages/xpce/CMakeFiles/plugin_pl2xpce.dir/src/txt/terminal.c.o -MF packages/xpce/CMakeFiles/plugin_pl2xpce.dir/src/txt/terminal.c.o.d -o packages/xpce/CMakeFiles/plugin_pl2xpce.dir/src/txt/terminal.c.o -c /Users/booris/install/swipl-devel/packages/xpce/src/txt/terminal.c
/Users/booris/install/swipl-devel/packages/xpce/src/txt/terminal.c:3624:37: error: use of undeclared identifier 'SIGWINCH'
 3624 |         pthread_kill(b->pty.client_thread, SIGWINCH);
      |                                            ^
1 error generated.

It looks almost as if there is an include missing in this file but I can’t tell for sure.

SIGWINCH should be in signal.h, but just including it naively in the file did not help.

There is an include file (<signal.h>) missing, though both on MacOS and Fedora 42 it was apparently pulled in indirectly. Added it explicitly to terminal.c, but as you say it didn’t help. That is really weird. SIGWINCH should be defined in any fairly recent Unix-like OS. As the code relies on the grantpt() PTY API, we know we have fairly recent Unix-like OS.

I made the call conditional on whether SIGWINCH is defined, so it will always compile (with a #warning).

The call is needed to make command line editing while resizing Epilog windows work correctly.

Which OS and version are we talking about?

MacOS Sequoia Version 15.7.2

I thought I’d verified this. Apparently not (correctly) :frowning: This reproduces on my Mac. The latest git does compile with a warning. First some other stuff then I’ll try to figure out why.

1 Like

Its a bit of a mystery. They only define SIGWINCH under some conditions, but I fail to set the right conditions. Setting the right #define while loading <signal.h> is apparently overruled somewhere else :frowning: Assuming they wont change the signal number I just hard coded it for MacOS if it is missing. That works. If anyone can find a cleaner solution, please make a PR.

Hi Jan, many thanks for all. I just pulled the latest version and you were right, of course, all is fixed now. The wasm version of SWI-Prolog is very nice, very efficient. We are all thankfull for this excellent job. All the best.