Ann: SWI-Prolog 9.0.2

Dear SWI-Prolog user,

SWI-Prolog 9.0.2 is ready for download. Why not 9.0.1? Because I
discovered an unacceptable issue while building 9.0.1 for MacOS and
as part of the file were already out, skipping a number is the only
option.

9.0.2 simply follows the 9.1.x series as there are no incompatible
changes and lots of cleanup and fixes. Highlights:

  • Fixed a couple of crashes and race conditions.
  • Allow compiliation under gcc -std=c11 -pedantic. Not used
    by default as it produces slower binaries because we cannot
    exploit some of GCCs extensions.
  • Support C backtraces on Linux arm platforms.
  • Fixed crypto_password_hash/2,3 hash incompatibility with
    8.4 series.
  • Updated sweep and cpp (SWI-cpp2.h).

MacOS annoucement

Since upgrade of the Mac build machine to Ventura (13.0.1) it seems
Xcode now longer builds proper binaries due to some issue related to
libGMP. The symptoms are non-reproducible random segmentation faults,
bus errors and memory management errors. This happens against the
“portable” libGMP version, build from source supporting MacOS 10.14
and later. It doesn’t seem to happen when linking to Macports libGMP.
As a work-around the binary bundle is now linked against LibBF, the
since recently available alternative to LibGMP. This causes some
slowdown on most operations big and rational numbers are involved in,
notably harming ration number arithmetic.

Enjoy --- Jan

SWI-Prolog Changelog since version 9.0.0

  • PORT: Build MacOS bundle using LibBF based big integers. Somehow the
    build for the universal binaries covering a large series of MacOS
    versions (since 10.14) breaks after uograde to MacOS Ventura when
    linking against libGMP. The results are random segfaults, bus errors
    and memory corruption.

  • FIXED: Possibly crash in breakpoint callback after GC/shift.

  • TEST: Make thread signal test behave better under high loads.

  • PORT: Make C backtraces work on ARM systems that use libunwind or
    glibc backtrace().

  • FIXED: Error handling if prolog_frame_attribute/3 using parent_frame
    runs out of stack. Careful review of this function after reported
    crash on 32 bit arm. Might be due to a stack shift in this code,
    but I doubt it and cannot reproduce the issue. Surely the current
    code is safer.

  • DOC: Document prolog_frame_attribute/2 with parent_frame(-Next)

  • TEST: test may result in another error on 32-bit platforms.

  • ADDED: library(streams). Intended for various tricks in capturing
    and redirecting streams. Currently only provides with_output_to/3
    that extends with_output_to/2 to allow capturing user_output and
    user_error.

  • FIXED: WASM shell: failure after clearing output.

  • UPDATE: Merge devel@b70e1737c01220e258830db17ade553164d5d9d1 -
    Fixed SSL password hash compatibility - Fixed race condition for
    creating functor objects - Fixed data corruption in clause/2 when
    decompiling the head - Fixed updating break table when removing a
    clause - Updated sweep - Made all sources stricty C11 compatible
    (gcc -std=c11 -pedantic)

  • FIXED: breakpoint removal when retracting a clause.

  • PORT: Provide MSVC alternatives for MinGW runtime support.

  • DEBUG: Dump Prolog stack on assertion error.

  • PORT: Drop old MSVC #ifdef code in favour of <inttypes.h>
    on all platforms.

  • PORT: Strict C11 support for VM instruction argument declaration.

  • PORT: Avoid GCC empty struct and named variadic arguments for cpp to
    make pl-wam.c compile under strict C11 standard. This does not solve
    full portability. pl-codetable.c suffers from related problems.

  • PORT: Fixed compilation for Windows after providing the libswipl
    patches

  • FIXED: Race condition between destroying indexes of thread-local
    predicates on thread exit and the clause garbage collector.

  • FIXED: Race condition for creating a functor. We must add the
    functor to the global functor array before we can declare it valid.

  • FIXED: thread_wait/2: race condition in updating threads waiting for
    a module.

  • FIXED: clause/2: possible error handling H_LIST_FF if there is a GC
    between handling the head and tail.

  • BUILD: Simplify configuration detection in the build environment
    by exploiting the libswipl flag if it is read-only (and thus
    reliable).

  • ADDED: swipl --dump-runtime-variables to provide the name of the
    shared object in PLLIBSWIPL.

  • ENHANCED: Set the Prolog flag libswipl based on dladdr() when
    possible.

  • PORT: The C11 standard does not allow for empty structs.

  • SNAP: CMAKE_INSTALL_LIBDIR seems undefined inside snapcraft, causing
    the build to fail.

  • SNAP: Latest snapcraft sets LD_LIBRARY_PATH to provide access to the
    “parts”. We should not consider this a broken environment.

  • DOC: Fixed LaTeX issues blocking the generation of the PDF manual.

Package cpp

  • FIXED: PlQuery() should resolve the predicate in the target module
    if one is provided as well as set the context. This bug breaks
    completion in swipl-win.

  • TEST: Avoid encoding issues when running the tests.

  • TEST: Fixed PL_scan_options() test for 32-bit platforms.

  • TEST: Avoid test_common.pl. Although avoiding duplication is good,
    it is not a good idea that when build with -DINSTALL_TESTS, this file
    ends up in the public library.

  • DOC: Fixed LaTeX errors and duplicate labels.

  • DOC: Add “philosophy” section on classes Remove some obsolete sections
    Some cleanup of markup

  • ADDED: PlPredicate, PlModule classes, support Pltermv(0) Also removed
    some unused parameter defaults and clean up initialization checks.

  • DOC: fix description of how exceptions work

  • TEST: Disabled invalid tests on Windows.

  • DOC: more details about exception handling

Package plunit

  • MODIFIED: extend message term plunit(end(Unit)) to plunit(end(Unit,
    Summary)) where summary provides the status and time spend on the unit.

Package ssl

  • FIXED: crypto_password_hash/2,3 assumed byte encoding for
    base64_encoded/3 while the default changed to UTF-8. Added test.

Package sweep

  • ADDED: ability to pass command line args directly to swipl

    • sweeprolog.el (sweeprolog-handle-command-line-args): new
      function, sets up command line argument handling using…
      (sweeprolog-command-line-function): new function.
  • ADDED: minor mode for moving to the next hole with TAB * sweeprolog.el
    (sweeprolog-forward-hole-on-tab-mode): new minor mode, binding
    TAB to… (sweeprolog-indent-or-forward-hole): new command. *
    README.org (“Filling Holes”): rephrase and mention new minor mode.

  • ENHANCED: indentation after infix operators * sweeprolog.el
    (sweeprolog-indent-line-after-infix): adhere to last line indentation
    even if non-standard, handle DCG RHS contexts and SSU guards. *
    sweeprolog-tests.el: add more tests for indentation.

  • ENHANCED: use argument names for holes in predicate
    completion * sweep.pl (predicate_argument_names/2):
    new predicate. (sweep_format_predicate/2): use it, and
    revise into… (sweep_format_predicate/4): new predicate.
    (sweep_predicate_completion_candidates): use it.

  • ADDED: make flymake optionally complain about implicit autoloads *
    sweeprolog.el (sweeprolog-note-implicit-autoloads): new user-option.
    (sweeprolog-analyze-fragment-flymake): use it. * README.org (“Managing
    Dependencies”): mention it.

  • ADDED: new command for updating use_module/autoload directives

    • sweep.pl (sweep_file_path_in_library/2): new predicate.
      (sweep_color_normalized/3): normalize autoload source paths. *
      sweeprolog.el (sweeprolog-analyze-buffer-with): new helper function.
      (sweeprolog-update-dependencies): new command.

Package xpce

  • PORT: Make the xpce source compile clean using GCC -pedantic flag.
    Note that an important part of the problems is that XPCE threads data
    and function pointers the same. This used to work with a cast to
    void*. This is not allowed in C11. It is allowed to cast both
    pointers and functions to intptr_t, so with a little detour we
    get where we need to be. Time will tell whether we will see systems
    where this conversion is not allowed.

Since upgrade of the Mac build machine to Ventura (13.0.1) it seems
Xcode now longer builds proper binaries due to some issue related to
libGMP. The symptoms are non-reproducible random segmentation faults,
bus errors and memory management errors. This happens against the
“portable” libGMP version, build from source supporting MacOS 10.14
and later. It doesn’t seem to happen when linking to Macports libGMP.

You haven’t tried Homebrew, have you? If not I’ll get to try when I upgrade to Ventura, which may turn out to be never :stuck_out_tongue:

–
Ian

I haven’t tried Homebrew. I have little clue what is going on. Could be Xcode, could be Ventura, could be M1 specific, could be due to the deployment target setting, etc. If someone wants to sort it out, rebuild the release building setup. See doc/Release.md. Notably use scripts/macos-deps.sh to build the dependencies and use the CMake command from scripts/make-distribution, dropping -DUSE_GMP=OFF that I added for this version.

If it reproduces, you see random crashes during the build, normally with segfault or bus error related to is/2. Just restarting the build makes it complete after a couple of trials. Next, try ctest and you see it crashing at many places. Run again, it crashes differently, etc.

Probably not a useful data point, but current development stream builds and tests fine (no segfaults) on Intel, MacOS 10.13 using:

cmake -DCMAKE_INSTALL_PREFIX=$HOME -G Ninja ..

Only anomaly I noticed was that a link to the binaries weren’t put into ~/bin as per my previous experience.
ctest -j 4 produced the following:

97% tests passed, 2 tests failed out of 77

Total Test time (real) =  24.44 sec

The following tests FAILED:
	 14 - swipl:save (Failed)
	 15 - swipl:files (Failed)

Just to confirm that the local build uses GMP, using the downloaded 9.1.1:

?- time((between(1,1000000,_),X is 1r2**1r2,fail)).
% 2,000,003 inferences, 5.226 CPU in 5.228 seconds (100% CPU, 382696 Lips)
false.

and my local build of the current dev stream:

?- time((between(1,1000000,_),X is 1r2**1r2,fail)).
% 2,000,003 inferences, 0.694 CPU in 0.695 seconds (100% CPU, 2880284 Lips)
false.

So different hardware, different (and quite old) MacOS, different Xcode, but all (unsurprisingly) seems to work fine.

Now also on msys2/MinGW. First time with all unit tests passing.

pacman -S mingw-w64-x86_64-swi-prolog

1 Like