Could someone review and test this patch on Linux? I think this is
the simplest way to solve the problem, but I'm not positive.
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.
* 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
(svn_fs_base__init): Renamed to...
(svn_fs_base__init2): in order to add a pool parameter and prevent
old modules from getting called with unexpected parameters. Also
pass the pool 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_init_func_t): Add pool parameter.
(svn_fs_base__init, svn_fs_fs__init): Renamed to...
(svn_fs_base__init2, svn_fs_fs__init2): in order to add a pool
parameter and prevent old modules from getting called with
unexpected parameters.
* subversion/libsvn_fs/fs-loader.c
(fs_type_defn): Refer to the new svn_fs_*__init2 functions.
(serialized_init): Move 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.
* subversion/libsvn_subr/atomic.c
(svn_atomic__init_once): Add pool parameter and pass it to
the init_func.
* subversion/libsvn_fs_fs/fs_fs.c
(svn_fs_fs__init): Renamed to...
(svn_fs_fs__init2): in order to add a pool parameter and prevent old
modules from getting called with unexpected parameters.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Apr 6 02:33:43 2007