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. 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
wolfgang.wink...@digital-concepts.com
mobil +43.699.19971172

dc:büro
digital concepts Novak Winkler OG
Software & Design
Landstraße 68, 5. Stock, 4020 Linz
www.digital-concepts.com
tel +43.732.997117.72
tel +43.699.1997117.72

Firmenbuchnummer: 192003h
Firmenbuchgericht: Landesgericht Linz



PS: BESUCHEN SIE UNSERE NEUE SHOP INFO SEITE: www.shop-info.at

diff -r 34cdce74dbcd include/nsconfig.h.in
--- a/include/nsconfig.h.in	Wed May 15 13:28:34 2013 +0200
+++ b/include/nsconfig.h.in	Wed Oct 09 08:12:56 2013 +0200
@@ -331,11 +331,6 @@
 # endif
 #endif
 
-/* Enable large inode numbers on Mac OS X 10.5.  */
-#ifndef _DARWIN_USE_64_BIT_INODE
-# define _DARWIN_USE_64_BIT_INODE 1
-#endif
-
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 
diff -r 34cdce74dbcd nsd/sockcallback.c
--- a/nsd/sockcallback.c	Wed May 15 13:28:34 2013 +0200
+++ b/nsd/sockcallback.c	Wed Oct 09 08:12:56 2013 +0200
@@ -359,8 +359,9 @@
 	 */
 
 	if (max <= table.numEntries) {
-	    max  = table.numEntries + 100;
-	    pfds = ns_realloc(pfds, (size_t)max);
+		max  += 100;
+		//pfds = ns_realloc(pfds, (size_t)max);
+		pfds = ns_malloc(sizeof(struct pollfd) * max);
 	}
 
         /*
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to