[4272] in BarnOwl Developers
[barnowl/barnowl] Properly check for dlsym() errors (PR #189)
daemon@ATHENA.MIT.EDU (kaduk)
Thu Aug 14 23:23:17 2025
Date: Thu, 14 Aug 2025 20:23:08 -0700
From: kaduk <notifications@github.com>
Reply-To: barnowl/barnowl <reply+ABCERSJ5C76KM56HJAMFAJWGVKERZEVBNHHMMI3AX4@reply.github.com>
To: barnowl/barnowl <barnowl@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
----==_mimepart_689ea81cecc2a_f1108012500
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
In closures.c we dlopen() the main process address space so we can get references to gvalue_from_sv, sv_from_gvalue, and perl_closure_new, but we only check for errors by seeing if dlerror() returns a non-NULL pointer (string). This is not correct, since we are only supposed to inspect dlerror()'s contents if one of a certain list of functions has returned an error (dlerror() returns information about the latest such error).
This causes problems on FreeBSD, where the NSS implementation in libc performs a dlsym() lookup of a "_nss_cache_cycle_protection_function" symbls, which fails in all processes other than nscd. The FreeBSD libc does not subsequently call dlerror() to clear the error string and so it remains cached until we inspect it, and we erroneously treat this cached value as indicating an error in our dlsym() usage, which trickles up and becomes a fatal error at startup.
Fix the issue by only calling dlerror() if we experienced an error return from dlsym() or dlclose(), clearing res to NULL in the success case.
You can view, comment on, or merge this pull request online at:
https://github.com/barnowl/barnowl/pull/189
-- Commit Summary --
* Properly check for dlsym() errors
-- File Changes --
M closures.c (10)
-- Patch Links --
https://github.com/barnowl/barnowl/pull/189.patch
https://github.com/barnowl/barnowl/pull/189.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/barnowl/barnowl/pull/189
You are receiving this because you are subscribed to this thread.
Message ID: <barnowl/barnowl/pull/189@github.com>
----==_mimepart_689ea81cecc2a_f1108012500
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p dir="auto">In closures.c we dlopen() the main process address space so we can get references to gvalue_from_sv, sv_from_gvalue, and perl_closure_new, but we only check for errors by seeing if dlerror() returns a non-NULL pointer (string). This is not correct, since we are only supposed to inspect dlerror()'s contents if one of a certain list of functions has returned an error (dlerror() returns information about the latest such error).</p>
<p dir="auto">This causes problems on FreeBSD, where the NSS implementation in libc performs a dlsym() lookup of a "_nss_cache_cycle_protection_function" symbls, which fails in all processes other than nscd. The FreeBSD libc does not subsequently call dlerror() to clear the error string and so it remains cached until we inspect it, and we erroneously treat this cached value as indicating an error in our dlsym() usage, which trickles up and becomes a fatal error at startup.</p>
<p dir="auto">Fix the issue by only calling dlerror() if we experienced an error return from dlsym() or dlclose(), clearing res to NULL in the success case.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/barnowl/barnowl/pull/189'>https://github.com/barnowl/barnowl/pull/189</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/barnowl/barnowl/pull/189/commits/1f65aee2011f5e938da110a9dcfe741b0a7c1d03" class="commit-link">1f65aee</a> Properly check for dlsym() errors</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/barnowl/barnowl/pull/189/files">1 file</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/barnowl/barnowl/pull/189/files#diff-b42e3e831b738f30ed6e9c250f5876657b5176a33a9cb4ec9727d056de3d5fa8">closures.c</a>
(10)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/barnowl/barnowl/pull/189.patch'>https://github.com/barnowl/barnowl/pull/189.patch</a></li>
<li><a href='https://github.com/barnowl/barnowl/pull/189.diff'>https://github.com/barnowl/barnowl/pull/189.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/barnowl/barnowl/pull/189">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABCERSPTS7PGHFME43IDDDL3NVHBZAVCNFSM6AAAAACD6PTYL6VHI2DSMVQWIX3LMV43ASLTON2WKOZTGMZDIMRQG4ZDSNI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><barnowl/barnowl/pull/189</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/barnowl/barnowl/pull/189",
"url": "https://github.com/barnowl/barnowl/pull/189",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>
----==_mimepart_689ea81cecc2a_f1108012500--