musl does not implement dlclose [1] the way apr tests it will always
fail, even though it is per posix. Backport a relevant fix

[1] 
https://wiki.musl-libc.org/functional-differences-from-glibc.html#Unloading-libraries

Signed-off-by: Khem Raj <raj.k...@gmail.com>
---
v2: Use a different approach instead of disabling the test with a backport from 
upstream

 ...Check-for-NULL-handle-in-apr_dso_sym.patch | 37 +++++++++++++++++++
 meta/recipes-support/apr/apr_1.7.4.bb         |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 
meta/recipes-support/apr/apr/0001-dso-Check-for-NULL-handle-in-apr_dso_sym.patch

diff --git 
a/meta/recipes-support/apr/apr/0001-dso-Check-for-NULL-handle-in-apr_dso_sym.patch
 
b/meta/recipes-support/apr/apr/0001-dso-Check-for-NULL-handle-in-apr_dso_sym.patch
new file mode 100644
index 00000000000..8ba181b8877
--- /dev/null
+++ 
b/meta/recipes-support/apr/apr/0001-dso-Check-for-NULL-handle-in-apr_dso_sym.patch
@@ -0,0 +1,37 @@
+From a25be1aaa92a6d2e7f4cc3fdfbb92e5a10b63035 Mon Sep 17 00:00:00 2001
+From: Greg Beard <gmbe...@googlemail.com>
+Date: Sat, 25 Mar 2023 08:31:36 +0000
+Subject: [PATCH] dso: Check for NULL handle in apr_dso_sym
+
+Upstream-Status: Backport 
[https://github.com/apache/apr/pull/40/commits/0efce00093b1ba405d91c7f0eab9755c8527eead]
+Signed-off-by: Khem Raj <raj.k...@gmail.com>
+---
+ dso/unix/dso.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/dso/unix/dso.c b/dso/unix/dso.c
+index fdd56f1..583d5de 100644
+--- a/dso/unix/dso.c
++++ b/dso/unix/dso.c
+@@ -173,6 +173,18 @@ APR_DECLARE(apr_status_t) 
apr_dso_sym(apr_dso_handle_sym_t *ressym,
+                                       apr_dso_handle_t *handle, 
+                                       const char *symname)
+ {
++    /* This is necessary for `testdso.c`. For some reason, musl
++     * builds fail the `test_unload_library` test if the below
++     * check isn't in place. `test_unload_library` unloads the
++     * library and then immediately calls this function. Maybe
++     * musl's `dlsym()` assumes the handle is never NULL and
++     * some UB is being invoked here...
++     */
++    if (handle->handle == NULL) {
++        handle->errormsg = "library not loaded";
++        return APR_ESYMNOTFOUND;
++    }
++
+ #if defined(DSO_USE_SHL)
+     void *symaddr = NULL;
+     int status;
+-- 
+2.42.0
+
diff --git a/meta/recipes-support/apr/apr_1.7.4.bb 
b/meta/recipes-support/apr/apr_1.7.4.bb
index 5ac7f4b93f7..d322629b66f 100644
--- a/meta/recipes-support/apr/apr_1.7.4.bb
+++ b/meta/recipes-support/apr/apr_1.7.4.bb
@@ -23,6 +23,7 @@ SRC_URI = "${APACHE_MIRROR}/apr/${BPN}-${PV}.tar.bz2 \
            file://0001-Add-option-to-disable-timed-dependant-tests.patch \
            
file://0001-configure-Remove-runtime-test-for-mmap-that-can-map-.patch \
            file://autoconf-2.73.patch \
+           file://0001-dso-Check-for-NULL-handle-in-apr_dso_sym.patch \
            "
 
 SRC_URI[sha256sum] = 
"fc648de983f3a2a6c9e78dea1f180639bd2fad6c06d556d4367a701fe5c35577"
-- 
2.42.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#187407): 
https://lists.openembedded.org/g/openembedded-core/message/187407
Mute This Topic: https://lists.openembedded.org/mt/101231753/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to