Bdb test fails on Mac OS

Hi,
While trying to build a clean clone of SWI-Prolog from the master branch (commit 3a4bbb648abc5e23882742669c95c7976d194723), I’m seeing the following issues (excuse the verbosity):

➜  build git:(master) ✗ ctest -j 8 --rerun-failed --output-on-failure
Test project /Users/eshelyaron/forks/swipl-devel/build
    Start 68: bdb:bdb
1/1 Test #68: bdb:bdb ..........................***Failed    0.08 sec
% PL-Unit: bdb
ERROR: /Users/eshelyaron/forks/swipl-devel/packages/bdb/test_bdb.pl:84:
	test loop: received error: BDB: Error 46196288 on <bdb>(0x102bf1a40): Unknown error: 46196288
ERROR: /Users/eshelyaron/forks/swipl-devel/packages/bdb/test_bdb.pl:96:
	test no_duplicates: received error: BDB: Error 46196928 on <bdb>(0x102c1b0e0): Unknown error: 46196928

SWI-Prolog [thread 1 (main) at Mon Aug 16 11:11:23 2021]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
  [0] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(save_backtrace+0x112) [0x101a90f82]
  [1] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(sigCrashHandler+0xdb) [0x101a914ab]
  [2] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(dispatch_signal+0x235) [0x1019f7805]
  [3] /usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7fff20516d7d]
  [5] /opt/local/lib/db53/libdb-5.3.dylib(__os_strdup+0x26) [0x102e0d852]
sh: addr2line: command not found
  [6] /Users/eshelyaron/forks/swipl-devel/build/packages/bdb/bdb4pl.so(pl_bdb_open+0x4f0) [0x102bc1150]
  [7] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(PL_next_solution___LD+0xeacc) [0x1019880cc]
  [8] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(query_loop+0x16b) [0x1019d5efb]
  [9] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(prologToplevel+0x51) [0x1019d65d1]
  [10] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(PL_initialise+0x1c34) [0x101a21bf4]
  [11] /Users/eshelyaron/forks/swipl-devel/build/src/swipl(main+0x2a) [0x10177cf4a]
  [12] /usr/lib/system/libdyld.dylib(start+0x1) [0x7fff204ecf5d]
Prolog stack:
  [24] bdb:bdb_open/4 [PC=1 in supervisor]
  [23] plunit_bdb:unit body/2 [PC=29 in clause 3]
  [22] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [20] plunit:call_det/2 [PC=11 in clause 1]
  [19] system:catch/3 [PC=2 in clause 1]
  [18] plunit:run_test_6/6 [PC=68 in clause 5]
  [17] plunit:run_test_once/5 [PC=41 in clause 1]
  [15] plunit:run_unit/1 [PC=184 in clause 3]
  [14] plunit:run_unit/1 [PC=8 in clause 2]
  [13] plunit:run_unit_and_check_errors/1 [PC=4 in clause 1]
  [12] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [10] plunit:run_tests/1 [PC=20 in clause 1]
  [9] test_bdb:test_bdb/0 [PC=8 in clause 1]
  [8] system:catch/3 [PC=2 in clause 1]
  [7] system:catch_with_backtrace/3 [PC=6 in clause 1]
  [6] $toplevel:run_init_goal/2 [PC=17 in clause 1]
  [4] $toplevel:run_init_goals/1 [PC=7 in clause 2]
  [3] $toplevel:initialise_prolog/0 [PC=94 in clause 1]
  [2] system:catch/3 [PC=2 in clause 1]
  [1] $toplevel:$initialise/0 [PC=12 in clause 1]
  [0] system:$c_call_prolog/0 [PC=0 in top query clause]
Running on_halt hooks with status 139
Killing 52146 with default signal handlers


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.09 sec

The following tests FAILED:
	 68 - bdb:bdb (Failed)
Errors while running CTest

Every once in a while, the output is a bit different, saying 68 - bdb:bdb (SEGFAULT) instead of 68 - bdb:bdb (Failed):

➜  build git:(master) ctest -j 8 --rerun-failed --output-on-failure
Test project /Users/eshelyaron/forks/swipl-devel/build
    Start 68: bdb:bdb
1/1 Test #68: bdb:bdb ..........................***Exception: SegFault  0.08 sec
% PL-Unit: bdb
ERROR: /Users/eshelyaron/forks/swipl-devel/packages/bdb/test_bdb.pl:84:
	test loop: received error: BDB: Error 280995392 on <bdb>(0x110bdfa40): Unknown error: 280995392
ERROR: /Users/eshelyaron/forks/swipl-devel/packages/bdb/test_bdb.pl:96:
	test no_duplicates: received error: BDB: Error 280996032 on <bdb>(0x110c070e0): Unknown error: 280996032

SWI-Prolog [thread 1 (main) at Mon Aug 16 09:39:31 2021]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
  [0] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(save_backtrace+0x112) [0x10fa79f82]
  [1] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(sigCrashHandler+0xdb) [0x10fa7a4ab]
  [2] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(dispatch_signal+0x235) [0x10f9e0805]
  [3] /usr/lib/system/libsystem_platform.dylib(_sigtramp+0x1d) [0x7fff20516d7d]
  [5] /opt/local/lib/db53/libdb-5.3.dylib(__os_strdup+0x26) [0x110df9852]
sh: addr2line: command not found
  [6] /Users/eshelyaron/forks/swipl-devel/build/packages/bdb/bdb4pl.so(pl_bdb_open+0x4f0) [0x110bad150]
  [7] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(PL_next_solution___LD+0xeacc) [0x10f9710cc]
  [8] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(query_loop+0x16b) [0x10f9beefb]
  [9] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(prologToplevel+0x51) [0x10f9bf5d1]
  [10] /Users/eshelyaron/forks/swipl-devel/build/src/libswipl.8.3.28.dylib(PL_initialise+0x1c34) [0x10fa0abf4]
  [11] /Users/eshelyaron/forks/swipl-devel/build/src/swipl(main+0x2a) [0x10f768f4a]
  [12] /usr/lib/system/libdyld.dylib(start+0x1) [0x7fff204ecf5d]
Prolog stack:
  [24] bdb:bdb_open/4 [PC=1 in supervisor]
  [23] plunit_bdb:unit body/2 [PC=29 in clause 3]
  [22] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [20] plunit:call_det/2 [PC=11 in clause 1]
  [19] system:catch/3 [PC=2 in clause 1]
  [18] plunit:run_test_6/6 [PC=68 in clause 5]
  [17] plunit:run_test_once/5 [PC=41 in clause 1]
  [15] plunit:run_unit/1 [PC=184 in clause 3]
  [14] plunit:run_unit/1 [PC=8 in clause 2]
  [13] plunit:run_unit_and_check_errors/1 [PC=4 in clause 1]
  [12] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [10] plunit:run_tests/1 [PC=20 in clause 1]
  [9] test_bdb:test_bdb/0 [PC=8 in clause 1]
  [8] system:catch/3 [PC=2 in clause 1]
  [7] system:catch_with_backtrace/3 [PC=6 in clause 1]
  [6] $toplevel:run_init_goal/2 [PC=17 in clause 1]
  [4] $toplevel:run_init_goals/1 [PC=7 in clause 2]
  [3] $toplevel:initialise_prolog/0 [PC=94 in clause 1]
  [2] system:catch/3 [PC=2 in clause 1]
  [1] $toplevel:$initialise/0 [PC=12 in clause 1]
  [0] system:$c_call_prolog/0 [PC=0 in top query clause]
Running on_halt hooks with status 139
Killing 51644 with default signal handlers


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.09 sec

The following tests FAILED:
	 68 - bdb:bdb (SEGFAULT)
Errors while running CTest

Also, when running ninja I’m seeing the following warnings:

[1877/2467] Building Java objects for jpl_jar.jar
Note: org/jpl7/fli/atom_t.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[2146/2467] Linking C executable src/swipl
ld: warning: dylib (/opt/local/lib/libtcmalloc_minimal.dylib) was built for newer macOS version (11.2) than being linked (11.0)
[2191/2467] Linking C shared module packages/archive/archive4pl.so
ld: warning: dylib (/opt/local/lib/libarchive.dylib) was built for newer macOS version (11.2) than being linked (11.0)
[2193/2467] Linking C shared module packages/ssl/crypto4pl.so
ld: warning: dylib (/opt/local/lib/libcrypto.dylib) was built for newer macOS version (11.2) than being linked (11.0)
[2194/2467] Linking C shared module packages/ssl/ssl4pl.so
ld: warning: dylib (/opt/local/lib/libssl.dylib) was built for newer macOS version (11.2) than being linked (11.0)
ld: warning: dylib (/opt/local/lib/libcrypto.dylib) was built for newer macOS version (11.2) than being linked (11.0)
[2467/2467] Generating home/doc/manindex.db

Any suggestions for getting a clean build?

Thanks :slight_smile:

Doesn’t reproduce. Just tried a clean build after upgrading Macports to the latest version for the dependencies. Tests run just fine. Using db62 from Macports.

Indeed I’ve updated Macports and db62 and now all the tests pass, thank you.