#2020/01/30 Patch has not yet been accepted upstream From 87b1eca2b719fb5e2d6f10352dcdb86f4d389ca9 Mon Sep 17 00:00:00 2001 From: Eric Timmons Date: Sat, 1 Feb 2020 17:33:59 -0500 Subject: [PATCH 3/5] Teach foreign.test.sh about noop dlclose implementations Musl libc's implementation of dlclose(3) is (intentionally) a noop (see: https://wiki.musl-libc.org/functional-differences-from-glibc.html). When running regression tests, test if dlclose is a noop and if so, skip all tests that depend on objects being unmapped. --- src/code/foreign-load.lisp | 2 +- tests/foreign.test.sh | 67 ++++++++++++++++++++++++++++---------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/code/foreign-load.lisp b/src/code/foreign-load.lisp index ada107c36..4510f2ccf 100644 --- a/src/code/foreign-load.lisp +++ b/src/code/foreign-load.lisp @@ -48,7 +48,7 @@ (defun load-shared-object (pathname &key dont-save) definitions; if a symbol was previously referenced through the object and is not present in the reloaded version an error will be signalled. Reloading may not work as expected if user or library-code has called dlopen(3) on the -same shared object. +same shared object or running on a system where dlclose(3) is a noop. LOAD-SHARED-OBJECT interacts with SB-EXT:SAVE-LISP-AND-DIE: diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh index fabba1246..53131bdd2 100755 --- a/tests/foreign.test.sh +++ b/tests/foreign.test.sh @@ -140,6 +140,28 @@ echo 'int late_foo = 43;' > $TEST_FILESTEM-c.c echo 'int late_bar() { return 14; }' >> $TEST_FILESTEM-c.c build_so $TEST_FILESTEM-c +cat > $TEST_FILESTEM-noop-dlclose-test.c < +#include + +int dlclose_is_noop () { + void * handle = dlopen("./$TEST_FILESTEM-noop-dlclose-test-helper.so", RTLD_NOW | RTLD_GLOBAL); + dlclose(handle); + + handle = dlopen("./$TEST_FILESTEM-noop-dlclose-test-helper.so", RTLD_NOW | RTLD_NOLOAD); + if (handle != NULL) { + return 1; + } + return 0; +} +EOF +build_so $TEST_FILESTEM-noop-dlclose-test + +cat > $TEST_FILESTEM-noop-dlclose-test-helper.c < $TEST_FILESTEM.base.lisp < $TEST_FILESTEM.test.lisp < $TEST_FILESTEM.test.lisp <