[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Issue 2732 -- Apache shutdown crash

From: D.J. Heap <djheap_at_gmail.com>
Date: 2007-04-16 04:32:10 CEST

Here's another iteration of this patch addressing Malcom's comments.
Review/comments and testing on Linux would be appreciated.

Log:

Fix the undefined behavior invoked when the fs module is dynamically
unloaded and the bdb cache tries to clean itself up.

This occurred because the bdb cache was allocated in the global pool
which gets cleaned up *after* the fs module has been unloaded from
memory (meaning the cleanup hook code may or may not still
actually be there depending on what the OS does with the newly freed
memory).

The fix is to pass the fs module's common_pool down to the fs_base
and fs_fs module's init routines so that they can allocate fs global
stuff and know that they can clean it up before they are unloaded.

In addition, this changes the fs modules vtables to get rid of the
serialized_init
function. Instead, we serialize open/create calls passing them the
common_pool and they then call their own init functions internally
as needed.

* subversion/libsvn_fs_base/bdb/env.h
 (svn_fs_bdb__init): Add a pool parameter that we can use to store
 the bdb cache in since it is fs module scoped.

* subversion/libsvn_fs_base/bdb/env.c
 (svn_fs_bdb__init, bdb_init_cb): Add and use the new fs module
 scoped pool for the bdb cache.

* subversion/libsvn_fs_base/fs.c
 (fs_vtable): Drop serialized_init function.
 (base_create, base_open, base_open_for_recovery): Add common_pool
 parameter and pass it on to the internal init functions as needed.
 (svn_fs_base__init): Add common_pool parameter and pass it on
 to the underlying init functions.

* subversion/include/svn_fs.h:
 (svn_fs_initialize): Update docs to note that undefined behavior can
 result if the fs module is dynamically loaded and the bdb fs is used.

* subversion/include/private/svn_atomic.h
 (svn_atomic__init_once): Add pool parameter.

* subversion/libsvn_fs/fs-loader.h
 (fs_library_vtable_t): Add common_pool parameter to create, open
 and open_for_recovery functions.
 (fs_init_func_t): Add common_pool parameter.
 (svn_fs_base__init, svn_fs_fs__init): Add common_pool parameter.
 (fs_vtable_t): Get rid of the serialized_init function which is now called
 internally by the open or create functions.

* subversion/libsvn_fs/fs-loader.c
 (common_pool): Document usage changes for common_pool.
 (serialized_init): Dropped and moved the best-effort common_pool init to...
 (get_library_vtable_direct): here in order to init it earlier when
 svn_fs_initialize is not called. Also pass the common_pool on
 to the init function for the underlying fs module.
 (acquire_fs_mutex, release_fs_mutex): New functions to get and drop
 the mutex guarding the fs module's common_pool.
 (svn_fs_create, svn_fs_open, svn_fs_recovery, svn_fs_create_berkeley,
 svn_fs_open_berkeley): Pass the common_pool parameter on to the
 underlying fs' functions after acquiring the fs mutex to serialize the
 calls.

* subversion/libsvn_subr/atomic.c
 (svn_atomic__init_once): Add pool parameter and pass it to
 the init_func.

* subversion/libsvn_fs_fs/fs.c
 (fs_vtable): Drop the serialized_init function which is now called internally
 by the open/create/open_for_recovery functions as needed.
 (fs_create, fs_open, fs_open_for_recovery): Add common_pool parameter
 and pass it on to internal init functions as needed.
 (svn_fs_fs__init): Add common_pool parameter.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Mon Apr 16 04:32:26 2007

This is an archived mail posted to the Subversion Dev mailing list.