I wasn't able to reproduce your crash, but there is definitely a problem - when using --enable-shared and --with-jemalloc together, the Ruby that gets built still uses libc's malloc and ignores jemalloc. This is because we pass -ljemalloc to the link line for libruby.so, but we don't pass it to ruby. This means that the built Ruby isn't marked as needing libjemalloc.so:
And because the dynamic linker (at least the glibc one) links libraries in breadth-first order, that means that libc.so.6 is linked before libjemalloc.so.2:
We need to pass -ljemalloc to the linker command line for the final Ruby executable. I'm playing around trying to find the right Autoconf magic spells for this now.