I'm trying to intercept calls to the pthread library using LD_PRELOAD.
I successfully intercept all calls (ex pthread_mutex_init, pthread_mutex_lock) except pthread_create. I don't get any error, the interception simply does not occur.
My code works on kernel 5.10 (glibc 2.31) but once on kernel 6.1 (glibc 2.36) it does not anymore. However I need kernel 6.1 for other things in the code so downgrading is not an option.
Has anything changed regarding the pthread_create function between kernels 5.10 and 6.1 (or glibc 2.31 and 2.36)?
My code: compiled as a shared library and then loaded using LD_PRELOAD.
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
#include <stdio.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) {
printf("[p] pthread_create\n");
return 0
}
int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr) {
printf("[p] pthread_mutex_init\n");
return 0
}
[p] pthread_mutex_init shows up but not [p] pthread_create.
Note: I know for a fact that pthread_create is used by the intercepted binary. Using the same code and same binary with kernel 5.10 [p] pthread_create gets printed out.