You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2014/12/05 01:01:30 UTC
svn commit: r1643138 - /subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
Author: stefan2
Date: Fri Dec 5 00:01:30 2014
New Revision: 1643138
URL: http://svn.apache.org/viewvc?rev=1643138&view=rev
Log:
Demonstrate the issue that r1555491 was supposed to solve. Right now,
this new test will segfault for FSFS on many platforms.
* subversion/tests/libsvn_fs/fs-test.c
(test_txn_pool_lifetime): New test.
(test_funcs): Register new test.
Modified:
subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1643138&r1=1643137&r2=1643138&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Fri Dec 5 00:01:30 2014
@@ -6599,6 +6599,47 @@ test_fsfs_config_opts(const svn_test_opt
return SVN_NO_ERROR;
}
+
+static svn_error_t *
+test_txn_pool_lifetime(const svn_test_opts_t *opts,
+ apr_pool_t *pool)
+{
+ /* Technically, the FS API makes no assumption on the lifetime of logically
+ * dependent objects. In particular, a txn root object may get destroyed
+ * after the FS object that it has been built upon. Actual data access is
+ * implied to be invalid without a valid svn_fs_t.
+ *
+ * This test verifies that at least the destruction order of those two
+ * objects is arbitrary.
+ */
+ svn_fs_t *fs;
+ svn_fs_txn_t *txn;
+ svn_fs_root_t *txn_root;
+
+ /* We will allocate FS in FS_POOL. Using a separate allocator makes
+ * sure that we actually free the memory when destroying the pool.
+ */
+ apr_allocator_t *fs_allocator = svn_pool_create_allocator(FALSE);
+ apr_pool_t *fs_pool = apr_allocator_owner_get(fs_allocator);
+
+ /* Create a new repo. */
+ SVN_ERR(svn_test__create_fs(&fs, "test-repo-pool-lifetime",
+ opts, fs_pool));
+
+ /* Create a TXN_ROOT referencing FS. */
+ SVN_ERR(svn_fs_begin_txn(&txn, fs, 0, pool));
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
+
+ /* Destroy FS. Depending on the actual allocator implementation,
+ * these memory pages becomes inaccessible. */
+ svn_pool_destroy(fs_pool);
+
+ /* Unclean implementations will try to access FS and may segfault here. */
+ svn_fs_close_root(txn_root);
+
+ return SVN_NO_ERROR;
+}
+
/* ------------------------------------------------------------------------ */
/* The test table. */
@@ -6724,6 +6765,8 @@ static struct svn_test_descriptor_t test
"get merging txns with newer revisions"),
SVN_TEST_OPTS_PASS(test_fsfs_config_opts,
"test creating FSFS repository with different opts"),
+ SVN_TEST_OPTS_PASS(test_txn_pool_lifetime,
+ "test pool lifetime dependencies with txn roots"),
SVN_TEST_NULL
};