From: Gustaf N. <ne...@wu...> - 2013-10-09 08:55:19
|
Am 09.10.13 08:47, schrieb Wolfgang Winkler: > Hello! > > We are using websockets on naviserver. After connections are > established, we create a callback for the read event with > ns_sockcallback and push them in the background with ns_chan. We hit a > limit of exactly 100 connections, which went away, when we commented > out the ns_sockcallback call. > > The problem is an invalid memory allocation. I've attached a patch, > which allows us to open much more connections, although we still get a > memory corruption at around 1000 connections, somtimes more, sometimes > less. Dear Wolfgang, many thanks for the patch. The allocation unit was clearly wrong (number of entries vs. number of bytes); the same problem exists as well in aolserver. The proposed change has from my understanding 2 flaws (a memory leak, and an underallocation when max is low (e.g. 100) and the number of entries in the hash table is high (e.g. 1000), then only 200 entries are allocated). The second problem might be related to your still existing problem, Please check your code again with the following patch: https://bitbucket.org/naviserver/naviserver/commits/c35cd3d2394e61dc55d4c3118d7a14a7a774cd52 best regards -gustaf neumann > TCL is compiled with Gustaf Neumanns memory allocator path. This is > the backtrace with the linux standard memory allocator > > *** glibc detected *** /usr/local/naviserver/bin/nsd: malloc(): > memory corruption: 0x000000000b371b60 *** > ======= Backtrace: ========= > /lib/libc.so.6(+0x71e16)[0x7f9de5cf5e16] > /lib/libc.so.6(+0x74ead)[0x7f9de5cf8ead] > /lib/libc.so.6(__libc_malloc+0x70)[0x7f9de5cfac70] > /usr/local/lib/libtcl8.5.so(Tcl_Alloc+0x15)[0x7f9de64b8475] > /usr/local/lib/libtcl8.5.so(+0xafdf2)[0x7f9de652ddf2] > /usr/local/lib/libtcl8.5.so(+0x330de)[0x7f9de64b10de] > /usr/local/lib/libtcl8.5.so(Tcl_EvalEx+0x16)[0x7f9de64b1aa6] > /usr/local/naviserver/lib/libnsd.so(Ns_TclEvalCallback+0x12b)[0x7f9de6e4682b] > /usr/local/naviserver/lib/libnsd.so(NsTclTraceProc+0x1c)[0x7f9de6e4a60c] > /usr/local/naviserver/lib/libnsd.so(+0x5984a)[0x7f9de6e4a84a] > /usr/local/naviserver/lib/libnsd.so(+0x59c45)[0x7f9de6e4ac45] > /usr/local/naviserver/lib/libnsd.so(Ns_TclAllocateInterp+0x15)[0x7f9de6e4aef5] > /usr/local/naviserver/lib/libnsd.so(NsTclSockProc+0x42)[0x7f9de6e56eb2] > /usr/local/naviserver/lib/libnsd.so(+0x5250f)[0x7f9de6e4350f] > /usr/local/naviserver/lib/libnsthread.so(NsThreadMain+0x7e)[0x7f9de67a067e] > /usr/local/naviserver/lib/libnsthread.so(+0x5029)[0x7f9de67a1029] > /lib/libpthread.so.0(+0x68ca)[0x7f9de586a8ca] > /lib/libc.so.6(clone+0x6d)[0x7f9de5d53b6d] > > We are running some test with the google allocator, but the results > are similar. > > Wolfgang > > -- > > *Wolfgang Winkler* > Geschäftsführung > wol...@di... > mobil +43.699.19971172 > |