LD_PRELOAD does not override malloc_usable_size from glibc

I’m trying to override glibc’s malloc_usable_size, but it seems LD_PRELOAD doesn’t work. To replicate on linux (glibc):

Save the following content in rmalloc.c:

#include <stddef.h>
#include <stdio.h>

size_t malloc_usable_size(const void *ptr) {
  return 0;

Compile with gcc -shared -fPIC rmalloc.c -o rmalloc.so; then start Julia with LD_PRELOAD=./rmalloc.so julia --project. In the REPL, run the following:

malloc_usable_size(ptr::Ptr{Cvoid}) = ccall(:malloc_usable_size, Csize_t, (Ptr{Cvoid},), ptr)
ptr = ccall(:malloc, Ptr{Cvoid}, (Csize_t,), 1024)
size = malloc_usable_size(ptr)
println("Usable size of allocated memory: ", size)

Then see that RMALLOC does not get printed and the allocated memory is not 0.

However, if I override malloc to return NULL, LD_PRELOAD crashes Julia which suggests the override succeeds. Why does this not also work for malloc_usable_size?