Yeah, I've overlooked the fact that malloc may still be already locked. I'll dig into history and see what can be done using pthread_set/getspecific.