I want to solve the following problem. Some C code in a shared library will call a pointer function which is a exported symbol of the shared libary
#include <stdio.h>
typedef void (*pCallBack)(const char *);
pCallBack one_pointer;
void errorPrint(const char * str)
{
   printf("my address = %p", one_pointer);
   fflush(stdout);
   (*one_pointer)(str);
}
let's compile that library as a shared library
gcc -fPIC -g -shared -o  call_back.so call_back.c
And now I want call it from Python, redefining dynamically the implementation of the pCallBack pointer
import ctypes
import sys
def myCallBack(str):
    print("inside python" % str)
    sys.stdout.flush()
libcallback = ctypes.CDLL("./call_back.so")
pointer_CallBack = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p)
libcallback.one_pointer = pointer_CallBack(myCallBack)
libcallback.errorPrint(b"one_string")
Unfortunately, it seems that the exported data one pointer could not be redefined. I also try in_dll function from ctypes but it does not solve the problem
When a try to run my Python script , I get the following
LD_PRELOAD="./call_back.so" python3 error.py
my address = (nil)[1]    2871869 segmentation fault (core dumped) 
Anyone knows that problem ?