BUG: crash on linux, craziness on OS X, valgrind to the rescue