-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_dllist
fails on NetBSD: dl_iterate_phdr doesn't report shared libraries
#131565
Comments
CC: @WardBrian |
Interesting! I don't have access to a NetBSD machine to test on, but the man page for dl_iterate_phdr on netbsd.org is almost identical to Linux's or FreeBSD's, so the behavior you're describing is surprising, to say the least The most immediate "fix" is probably to update the availability to only |
Yes, |
Yes, this is a feasible solution. However, I think it is more important to find the underlying problem. |
I suppose the right place to start is probably checking the basic operation of the c function. If I compile and run this locally: #define _GNU_SOURCE // presumably not necessary on netbsd, but harmless?
#include <link.h>
#include <stdio.h>
int callback(struct dl_phdr_info *info, size_t size, void *data) {
printf("name=%s, base=%p, size=%d\n", info->dlpi_name, (void *)info->dlpi_addr, info->dlpi_phnum);
return 0;
}
int main(void) {
dl_iterate_phdr(callback, NULL);
return 0;
} I get
which matches
Could you run a similar experiment? |
╰─$ cat main.c
#define _GNU_SOURCE // presumably not necessary on netbsd, but harmless?
#include <link.h>
#include <stdio.h>
int callback(struct dl_phdr_info *info, size_t size, void *data) {
printf("name=%s, base=%p, size=%d\n", info->dlpi_name, (void *)info->dlpi_addr, info->dlpi_phnum);
return 0;
}
int main(void) {
dl_iterate_phdr(callback, NULL);
return 0;
} ╰─$ gcc main.c -o main
╰─$ ./main
name=./main, base=0x0, size=7
name=/usr/lib/libc.so.12, base=0x7ebdaac00000, size=8
name=/usr/libexec/ld.elf_so, base=0x7f7fa6e00000, size=7
╰─$ ldd ./main
./main:
-lc.12 => /usr/lib/libc.so.12
╭─blue@home ~
╰─$ uname -a
NetBSD home.localhost 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64 |
Ok, interesting! Mind trying the next level up? file main.c: #define _GNU_SOURCE
#include <link.h>
#include <stdio.h>
int callback(struct dl_phdr_info *info, size_t size, void *data) {
printf("name=%s, base=%p, size=%d\n", info->dlpi_name,
(void *)info->dlpi_addr, info->dlpi_phnum);
return 0;
}
__attribute__((visibility("default"))) void call_me(void) {
dl_iterate_phdr(callback, NULL);
} gcc -shared -fpic -o libdllist_test.so main.c
python -c "import ctypes; ctypes.CDLL('./libdllist_test.so').call_me()" In particular, the output should contain something like
as well as the system libraries. |
Bug report
Bug description:
The
test_dllist
tests inLib/test/test_ctypes/test_dllist.py
are failing on NetBSD. The issue appears to be that thedl_iterate_phdr
function on NetBSD does not report the same information about loaded shared libraries as it does on Linux and other platforms.Specifically, on NetBSD,
dl_iterate_phdr
only returns the main Python executable and doesn't include any of the shared libraries that are actually loaded../python -m test test_ctypes -m test_dllist -v
Output:
Running
ldd
on the Python executable confirms that these libraries are actually loaded:CPython versions tested on:
CPython main branch, 3.14
Operating systems tested on:
Other
The text was updated successfully, but these errors were encountered: