From: Stephen D. <sd...@gm...> - 2006-04-13 21:58:29
|
Uh oh... There could well be problems with the cache code, but I think it runs deeper than that. I've found a couple of problems which are easier to trigger, for testing: make runtest ns_info nsd ...produces garbage. make runtest ns_cache_create c 1000 ns_cache_incr c k 1 ns_cache_create c k ...produces an error. Memory corruption. Looking a little deeper, I don't see how the first ever passed it's test. nsconf.nsd end up pointing to heap memory, allocated by Tcl.=20 But the Tcl function is called twice (don't have it in front of me, FindExecutable?), and the second time it frees and then allocates a buffer for the path again, so the original nsconf.nsd is pointing at deallocated memory. Easy to fix, but puzzling why this didn't show up before. The code for ns_cache_incr looks reasonable. The error seems to happen in the Tcl core when it tries to parse the cache value as an integer by using the regexp engine. I think by this point memory is already trashed. Whatever is trashing memory it's happening really early. I tried with only one virtual server configured, tried using the control port instead of the built in command shell etc. but it's still there. I've also tried running with Tcl mem debugging enabled, thread allocator disabled, Linux MALLOC_CHECK_ enabled -- no joy. The bad news is that I noticed something months ago. I tried linking against a Tcl 8.5 snapshot from CVS and the test suite crashed it every time. I thought it was just an unstable Tcl. Unless anyone has any bright ideas, I'm going to test snapshots from CVS until the problem goes away, when I get time... On 4/7/06, Vlad Seryakov <vl...@cr...> wrote: > This is what i discovered yesterday, i ported my application from > ns_cache module to internal Tcl cache API and got SEGV crashes. Under > high concurrency when inside ns_cache_eval i call another ns_cache_set C > cache API crashes, using ns_cache it was working the last couple of > years. It always crashes in this place. > > Loaded symbols for /lib/libresolv.so.2 > #0 Push (ePtr=3D0xa92ab878) at cache.c:904 > 904 ePtr->cachePtr->firstEntryPtr->prevPtr =3D ePtr; > (gdb) bt > #0 Push (ePtr=3D0xa92ab878) at cache.c:904 > #1 0xb7f59cb5 in Ns_CacheWaitCreateEntry (cache=3D0x839e858, > key=3D0x867fb98 "6", newPtr=3D0xabc3575c, timeout=3D360) at cache.c:295 > #2 0xb7f79a5b in CreateEntry (itPtr=3D0x888bcf8, cache=3D0x839e858, > key=3D0x867fb98 "6", newPtr=3D0x8a990000, timeout=3D360) > at tclcache.c:686 > #3 0xb7f7a01c in NsTclCacheSetObjCmd (arg=3D0x888bcf8, interp=3D0x88b512= 0, > objc=3D-1969684480, objv=3D0x8a990000) at tclcache.c:367 > #4 0xb7ea9143 in TclEvalObjvInternal (interp=3D0x88b5120, objc=3D4, > objv=3D0x88c775c, command=3D0x0, length=3D0, flags=3D0) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:3085 > #5 0xb7ed2fa0 in TclExecuteByteCode (interp=3D0x88b5120, codePtr=3D0x891= cb80) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclExecu= te.c:1419 > #6 0xb7ed8ee8 in TclCompEvalObj (interp=3D0x88b5120, objPtr=3D0x888ec38) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclExecu= te.c:981 > #7 0xb7eab94b in Tcl_EvalObjEx (interp=3D0x88b5120, objPtr=3D0x888ec38, > flags=3D0) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:4049 > #8 0xb7f7a521 in NsTclCacheEvalObjCmd (arg=3D0x888bcf8, interp=3D0x88b51= 20, > objc=3D6, objv=3D0x88c7744) at tclcache.c:167 > #9 0xb7ea9143 in TclEvalObjvInternal (interp=3D0x88b5120, objc=3D6, > objv=3D0x88c7744, command=3D0x0, length=3D0, flags=3D0) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:3085 > #10 0xb7ed2fa0 in TclExecuteByteCode (interp=3D0x88b5120, codePtr=3D0x891= 74e0) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclExecu= te.c:1419 > #11 0xb7ed8ee8 in TclCompEvalObj (interp=3D0x88b5120, objPtr=3D0x888f2f8) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclExecu= te.c:981 > #12 0xb7eab94b in Tcl_EvalObjEx (interp=3D0x88b5120, objPtr=3D0x888f2f8, > flags=3D0) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:4049 > #13 0xb7eb0dba in Tcl_ForObjCmd (dummy=3D0x0, interp=3D0x88b5120, objc=3D= 5, > objv=3D0xabc362ac) > at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclCmdAH= .c:1638 > #14 0xb7ea9143 in TclEvalObjvInternal (interp=3D0x88b5120, objc=3D5, > objv=3D0xabc362ac, > command=3D0x840144f "for {set j 0} {$j < 1000} {incr j} {\n", ' ' > <repeats 16 times>, "for {set x 0} {$x < 10000} {incr x} {set a b}\n", ' > ' <repeats 16 times>, "ns_cache_eval -ttl 1 c1 k1 {\n", ' ' <repeats 18 > times>, "ns_cache_set c1 $j $j\n", ' ' <repeats 16 times>..., > length=3D276, flags=3D0) at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:3085 > #15 0xb7eaace4 in Tcl_EvalEx (interp=3D0x88b5120, > script=3D0x8401440 " \n", ' ' <repeats 12 times>, "for {set j 0} {$= j > < 1000} {incr j} {\n", ' ' <repeats 16 times>, "for {set x 0} {$x < > 10000} {incr x} {set a b}\n", ' ' <repeats 16 times>, "ns_cache_eval > -ttl 1 c1 k1 {\n", ' ' <repeats 18 times>, "ns_cache_set c1 $j $j\n > "..., numBytes=3D299, flags=3D0) at > /home/vlad/src/lmbox/linux/src/tcl/src/tcl8.4.12/unix/../generic/tclBasic= .c:3687 > #16 0xb7f7f58e in Ns_TclEval (dsPtr=3D0x0, server=3D0x8a990000 <Address > 0x8a990000 out of bounds>, > script=3D0x8a990000 <Address 0x8a990000 out of bounds>) at tclinit.c= :227 > #17 0xb7f8c48f in NsTclThread (arg=3D0x8401438) at tclthread.c:660 > #18 0xb7f3c524 in NsThreadMain (arg=3D0x82ac7e8) at thread.c:224 > #19 0xb7f3d2dd in ThreadMain (arg=3D0x8a990000) at pthread.c:736 > #20 0xb7cd5240 in start_thread () from /lib/tls/libpthread.so.0 > > > Vlad Seryakov wrote: > > Update of /cvsroot/naviserver/naviserver/tests > > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27307 > > > > Modified Files: > > ns_cache.test > > Log Message: > > Hard cache test which works in case of ns_cache modules but core dumps = using ns_cache_eval > > > > > > Index: ns_cache.test > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > RCS file: /cvsroot/naviserver/naviserver/tests/ns_cache.test,v > > retrieving revision 1.4 > > retrieving revision 1.5 > > diff -C2 -d -r1.4 -r1.5 > > *** ns_cache.test 5 Apr 2006 18:24:57 -0000 1.4 > > --- ns_cache.test 6 Apr 2006 23:20:44 -0000 1.5 > > *************** > > *** 300,304 **** > > for {set j 0} {$j < 1000} {incr j} { > > for {set x 0} {$x < 10000} {incr x} {set a b} > > ! ns_cache_eval c1 k1 {return a} > > ns_thread yield > > } > > --- 300,307 ---- > > for {set j 0} {$j < 1000} {incr j} { > > for {set x 0} {$x < 10000} {incr x} {set a b} > > ! ns_cache_eval -ttl 1 c1 k1 { > > ! ns_cache_set c1 $j $j > > ! return a > > ! } > > ns_thread yield > > } > > *************** > > *** 308,311 **** > > --- 311,315 ---- > > for {set j 0} {$j < 1000} {incr j} { > > for {set x 0} {$x < 10000} {incr x} {set a b} > > + ns_cache_get c1 $j > > ns_cache_flush c1 > > ns_thread yield > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang= uage > > that extends applications into web and mobile media. Attend the live we= bcast > > and join the prime developer group breaking into this new coding territ= ory! > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > > _______________________________________________ > > naviserver-commits mailing list > > nav...@li... > > https://lists.sourceforge.net/lists/listinfo/naviserver-commits > > > > -- > Vlad Seryakov > 571 262-8608 office > vl...@cr... > http://www.crystalballinc.com/vlad/ > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel > |