-
-
Notifications
You must be signed in to change notification settings - Fork 29.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
ctypes.CDLL fails on FreeBSD: ld-elf.so.1: Can't find module with TLS index 1 #92828
Comments
Did you manage to solve this problem? If so, how? |
Hi, Best Regards, #include <link.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
/**
* mwe.c
* Compile via:
* gcc -rdynamic mwe.c -o mwe -g -D_GNU_SOURCE
* or
* clang -rdynamic mwe.c -o mwe -g -D_GNU_SOURCE
*/
static int callback(struct dl_phdr_info *info, size_t size, void *data) {
//A simple callback function
printf("Name: \"%s\" (%d segments)\n", info->dlpi_name, info->dlpi_phnum);
return 0;
}
typedef int (*lib_func)(int (*callback)(struct dl_phdr_info *, size_t, void *), void* data);
int call_from_libc(){
/**
* Calls dl_iterate_phdr indirectly by loading libc via dlopen
* */
void *handle = NULL;
lib_func func = NULL;
handle = dlopen("/lib/libc.so.7",RTLD_NOW|RTLD_NOLOAD);// Put the name of your libc shared object
if (handle == NULL){
fprintf(stderr, "Unable to open lib: %s\n", dlerror());
return -1;
}
func = dlsym(handle, "dl_iterate_phdr");
if (func == NULL) {
fprintf(stderr, "Unable to get symbol\n");
return -1;
}
func(callback, NULL);
return 0;
}
int main(int argc, char *argv[]) {
printf("Direct call:\n");
dl_iterate_phdr(callback, NULL);//It works
printf("Indirect call:\n");
call_from_libc();//It causes 'ld-elf.so.1: Can't find module with TLS index 1'
exit(EXIT_SUCCESS);
} |
@ptrajdos Thank you very much for this testcase. |
The answer is:
|
libc in FreeBSD was modified such that the |
This code fails on FreeBSD 13 with Python-3.8:
It fails with the message:
This code is from the Python library threadpoolctl that fails with the same error message.
The text was updated successfully, but these errors were encountered: