I still haven't found a solution to this problem, but that is irrelevant now. The segmentation fault can only be reproduced in the 64 bit darwin libc. Furthermore, running the program with valgrind on the darwin suppresses the fault.
This led me to the conclusion that the problem is in the code, rather than the libraries. The code was not mine at the beginning, hence it's not my problem anymore. The program in some stage tries to access unallocated memory and my guess is that using glibc somehow compensates this error.