Dear friends, When runnig nsdbi + nsdbipg for a while on OpenACS.org, we experienced infrequent crashes. The cause turned out to be a subtle interaction between ns-cache and nsdbipg in cache pruning. When the cache becomes full, an call to Ns_CacheSetValueExpires() calls the pruning code, which calls eventually CacheUnsetValue, FreeStatement (in the nsdbi module) and the prepareCloseProc (in the nsdbipg module, freeing the prepared statement name).
The problem was that nsdbipg calls during cleanup Dbi_ExecDirect (in nsdbi), which wants to cache the prepare info for that cleanup statement, via Ns_CacheSetValueExpires. Therefore, before the above Ns_CacheUnsetValue finishes, it is called again with the still full cache, it wants to prune the cache and calls Ns_CacheUnsetValue() again and a double free happens on the statement name in prepareCloseProc (or maybe later on the the free operation of the statement). here is the (simplified) call chain: Ns_CacheSetValueExpires -> Ns_CacheDeleteEntry -> Ns_CacheUnsetValue -> FreeStatement -> prepareCloseProc -> Dbi_ExecDirect -> Dbi_Prepare -> Ns_CacheSetValueExpires -> Ns_CacheUnsetValue -> -> FreeStatement -> prepareCloseProc -> crash There are at least two ways to address this problem: (a) to avoid ns-cache add-operations from a ns-cache freeProc, or (b) to make CacheUnsetValue more robust in this respect. I've fixed the problem via (b) since that is more general (and less work). It is not completely unlikely, that this fixes as well some other unreported crashes during cache pruning, some other modules might have similar interactions. all the best -gustaf neumann ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel