[Bug 286505] dlopen deadlocks when target library contains IFUNC
[email protected] Thu, 01 May 2025 16:46:11 +0000
| Newsgroups | gmane.os.freebsd.devel.threading |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D286505
Bug ID: 286505
Summary: dlopen deadlocks when target library contains IFUNC
Product: Base System
Version: Unspecified
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: threads
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
An ifunc resolver enters _rtld_bind, which attempts to acquire _rtld_bind_l=
ock.
But since we are in the middle of dlopen, the lock has been acquired alread=
y,
hence deadlocking.
This is similar to bug #286502 but does not involve filter libraries.
Tested on AArch64 but should be reproducible on AMD64. pthread required.
Commands:
cc main.c -lthr -Wl,-rpath=3D. -o main
cc foo.c -shared -o foo.so
./main
Setup:
$ cat main.c
#include <dlfcn.h>
int main() {
dlopen("foo.so", RTLD_LAZY);
}
$ cat foo.c
#include <stdio.h>
static void foo_impl() {
}
static void *foo_resolver() {
puts("foo_resolver()");
return &foo_impl;
}
void foo() __attribute__((ifunc("foo_resolver")));
void (*foo_ptr)() =3D &foo;
--=20
You are receiving this mail because:
You are the assignee for the bug.=