<div dir="ltr">Thanks for much.<div><br></div><div>I need some other wheel.</div><div>But, I hope jemalloc handle properly later. :-)</div><div>Anyway, thanks again!</div><div><br></div><div>-----</div><div>weon</div><div>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/24 Jason Evans <span dir="ltr"><<a href="mailto:jasone@canonware.com" target="_blank">jasone@canonware.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Oct 23, 2013, at 8:11 PM, Taehwan Weon <<a href="mailto:taehwan.weon@gmail.com">taehwan.weon@gmail.com</a>> wrote:<br>
> I am using jemalloc-3.4.0 on Centos 6.3<br>
> When my SEGV signal handler tried to dump call stacks, hang occurred as following.<br>
> I don't know why libc's fork called jemalloc_prefork even if I didn't set LD_PRELOAD.<br>
><br>
> #0  0x000000351d60d654 in __lll_lock_wait () from /lib64/libpthread.so.0<br>
> #1  0x000000351d608f4a in _L_lock_1034 () from /lib64/libpthread.so.0<br>
> #2  0x000000351d608e0c in pthread_mutex_lock () from /lib64/libpthread.so.0<br>
> #3  0x00002b59a8055d6d in malloc_mutex_lock (mutex=0x2b59a84a4320) at include/jemalloc/internal/mutex.h:77<br>
> #4  malloc_mutex_prefork (mutex=0x2b59a84a4320) at src/mutex.c:109<br>
> #5  0x00002b59a8044c32 in arena_prefork (arena=0x2b59a84a3d40) at src/arena.c:2344<br>
> #6  0x00002b59a803f555 in jemalloc_prefork () at src/jemalloc.c:1760<br>
> #7  0x000000351ca9a2a6 in fork () from /lib64/libc.so.6<br>
> #8  0x000000351ca6200d in _IO_proc_open@@GLIBC_2.2.5 () from /lib64/libc.so.6<br>
> #9  0x000000351ca62269 in popen@@GLIBC_2.2.5 () from /lib64/libc.so.6<br>
> #10 0x00002b59a71bc1f9 in backtrace_lineinfo (number=1, address=<value optimized out>, symbol=0x2b61f4000918 "/usr/lib64/libnc.so.2 [0x2b59a71bc3b1]") at cfs_apix.c:363<br>
> #11 0x00002b59a71bc3ff in nc_dump_stack (sig=<value optimized out>) at cfs_apix.c:423<br>
> #12 <signal handler called><br>
> #13 0x00002b59a8047332 in arena_dalloc_bin_locked (arena=0x2b59a84a3d40, chunk=0x2b61ef000000, ptr=<value optimized out>, mapelm=<value optimized out>) at src/arena.c:1717<br>
> #14 0x00002b59a805fba4 in tcache_bin_flush_small (tbin=0x2b61ef107128, binind=8, rem=9, tcache=0x2b61ef107000) at src/tcache.c:127<br>
> #15 0x00002b59a805fcd4 in tcache_event_hard (tcache=0x80) at src/tcache.c:39<br>
> #16 0x00002b59a80428d9 in tcache_event (ptr=0x2b61efd26dc0) at include/jemalloc/internal/tcache.h:271<br>
> #17 tcache_dalloc_small (ptr=0x2b61efd26dc0) at include/jemalloc/internal/tcache.h:408<br>
> #18 arena_dalloc (ptr=0x2b61efd26dc0) at include/jemalloc/internal/arena.h:1003<br>
> #19 idallocx (ptr=0x2b61efd26dc0) at include/jemalloc/internal/jemalloc_internal.h:913<br>
> #20 iqallocx (ptr=0x2b61efd26dc0) at include/jemalloc/internal/jemalloc_internal.h:932<br>
> #21 iqalloc (ptr=0x2b61efd26dc0) at include/jemalloc/internal/jemalloc_internal.h:939<br>
> #22 jefree (ptr=0x2b61efd26dc0) at src/jemalloc.c:1272<br>
> #23 0x00002b59a71c958b in __nc_free (p=0x2b61efd26dd0, file=<value optimized out>, lno=<value optimized out>) at util.c:1916<br>
> #24 0x00002b59a71cb975 in tlcq_dequeue (q=0x2b59a9ee3210, msec=<value optimized out>) at tlc_queue.c:215<br>
> #25 0x00002b59a71c154b in tp_worker (d=<value optimized out>) at threadpool.c:116<br>
> #26 0x000000351d60683d in start_thread () from /lib64/libpthread.so.0<br>
> #27 0x000000351cad503d in clone () from /lib64/libc.so.6<br>
><br>
> Any hint will be highly appreciated.<br>
<br>
</div></div>jemalloc calls pthread_atfork(3) in order to install functions that get called just before and after fork(2).  In this case your application is causing a signal while deep inside jemalloc (very likely due to memory corruption), with locks already acquired.  Deadlock obviously results.  To my surprise, fork() is actually listed in the signal(7) manual page as an async-signal-safe function, though popen(3) isn't, and it would probably allocate memory if it got past the hang during fork().  If you were to call fork() directly, then you'd be hitting a peculiar failure condition and we could make a case for jemalloc's behavior being questionable, but as your signal handler is written, it is simply unreliable due to calling something outside the list of async-signal-safe functions.<br>

<span class="HOEnZb"><font color="#888888"><br>
Jason<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><p style="line-height:115%"><span style="line-height:115%;font-size:9pt"><strong>원 태환</strong>ㅣ</span><span style="line-height:115%;font-size:9pt"> 부사장/COO</span></p>
<p><span style="font-size:9pt" lang="EN-US"><u></u> <u></u></span></p><p><span style="font-size:9pt" lang="EN-US">(</span><span style="font-size:9pt">주<span lang="EN-US">)</span>솔박스 <span lang="EN-US"><u></u><u></u></span></span></p>
<p><span style="font-size:9pt">서울시 강남구 역삼동<span lang="EN-US"> 747-2 </span>해성빌딩<span lang="EN-US"> 7</span>층<span lang="EN-US"><u></u><u></u></span></span></p><p><b><span style="color:rgb(192,0,0);font-size:9pt" lang="EN-US">T</span></b><span style="color:rgb(64,64,64);font-size:9pt" lang="EN-US"> </span><span style="color:rgb(31,73,125);font-size:9pt" lang="EN-US"> </span><span style="font-size:9pt" lang="EN-US">02-2182-3600 </span><span style="color:rgb(31,73,125);font-size:9pt" lang="EN-US">    </span><b><span style="color:rgb(192,0,0);font-size:9pt" lang="EN-US">F</span></b><span style="color:rgb(64,64,64);font-size:9pt" lang="EN-US"> </span><span style="font-size:9pt" lang="EN-US">02-2058-2651 </span><span style="color:rgb(64,64,64);font-size:9pt" lang="EN-US"> <u></u><u></u></span></p>
<p><b><span style="color:rgb(192,0,0);font-size:9pt" lang="EN-US">M</span></b><span style="color:rgb(64,64,64);font-size:9pt" lang="EN-US"> </span><span style="font-size:9pt" lang="EN-US">010-3335-8258  </span><b><span style="color:rgb(192,0,0);font-size:9pt" lang="EN-US">E</span></b><span style="color:rgb(64,64,64);font-size:9pt" lang="EN-US"> </span><span style="font-size:9pt" lang="EN-US"><a href="mailto:weon@solbox.com" target="_blank">weon@solbox.com</a></span></p>

</div>