On Oct 16 23:56, Yucong Sun wrote: > Hi, > > Throught some frustrating and furious debugging I now understand the > core issue here. CYGWIN calls malloc provided by jemalloc during > initializations, which in turn calls pthreads functions, which in > turn uses malloc, which also uses pthreads, causing a deadlock. > > Now, is there anyway to workaround this issue? Not quickly, at least. I looked into thread.cc and pthread.cc and only found two uses of malloc, one of them should only occur when pthread_exit'ing the main thread, the other in pthread_getattr_np. The first shouldn't matter to jemalloc (or, does it?), the second one I just eliminated. What exactly is the malloc problem you're seeing? In the long run it would be very nice if we could get jemalloc working as the default malloc implementation in Cygwin, replacing dlmalloc. This would allow to get rid of the slow global locking in malloc_wrapper.cc. Historical note: At one point I tried to integrate ptmalloc3, but it always had some unwanted side-effects and fixing them would have been very complicated at the time. So, if you're looking into getting jemalloc into Cygwin, feel free to discuss this further on the cygwin-developers mailing list. Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat