You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Greg Stein <gs...@lyra.org> on 2002/02/05 19:07:25 UTC
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
On Tue, Feb 05, 2002 at 07:24:06AM -0600, yoshiki@tigris.org wrote:
> Author: yoshiki
> Date: 2002-02-05 13:24 GMT
> New Revision: 1186
>
> Modified:
> trunk/subversion/bindings/ruby/fs.c
> Log:
> * fs.c (free_fs): Do not call svn_fs_close_fs because it will toss pool fs is
> allocated. The pool might be also used by Svn::Repos object.
How could the Svn::Repos object use a pool that is internal to the svn_fs
object? This doesn't make sense to me...
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Karl Fogel <kf...@newton.ch.collab.net>.
Yoshiki Hayashi <yo...@xemacs.org> writes:
> Ah, then this is the bug in svn_repos_open?
>
> libsvn_repos/repos.c:
>
> svn_error_t *
> svn_repos_open (svn_repos_t **repos_p,
> const char *path,
> apr_pool_t *pool)
> {
> apr_status_t apr_err;
> svn_repos_t *repos;
>
> /* Allocate a repository object. */
> repos = apr_pcalloc (pool, sizeof (*repos));
> repos->pool = pool;
>
> /* Initialize the repository paths. */
> repos->path = apr_pstrdup (pool, path);
> init_repos_dirs (repos, pool);
>
> /* Initialize the filesystem object. */
> repos->fs = svn_fs_new (pool);
That's only svn_repos_open... let's look at svn_fs_new()...
^^^^^
svn_fs_t *
svn_fs_new (apr_pool_t *parent_pool)
{
svn_fs_t *new;
/* Allocate a new filesystem object in its own pool, which is a
subpool of POOL. */
{
apr_pool_t *pool = svn_pool_create (parent_pool);
new = apr_pcalloc (pool, sizeof (svn_fs_t));
new->pool = pool;
}
new->warning = default_warning_func;
apr_pool_cleanup_register (new->pool, (void *) new,
(apr_status_t (*) (void *)) cleanup_fs_apr,
apr_pool_cleanup_null);
return new;
}
Looks safe for svn_fs_close() to me...
-Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Yoshiki Hayashi <yo...@xemacs.org>.
Greg Stein <gs...@lyra.org> writes:
> > svn_error_t *
> > svn_repos_open (svn_repos_t **repos_p,
> > const char *path,
> > apr_pool_t *pool)
> > {
> > apr_status_t apr_err;
> > svn_repos_t *repos;
> >
> > /* Allocate a repository object. */
> > repos = apr_pcalloc (pool, sizeof (*repos));
> > repos->pool = pool;
> >
> > /* Initialize the repository paths. */
> > repos->path = apr_pstrdup (pool, path);
> > init_repos_dirs (repos, pool);
> >
> > /* Initialize the filesystem object. */
> > repos->fs = svn_fs_new (pool);
>
> This says to create repos->fs in 'pool'. The FS does so, as a child pool.
> When you call close_fs(), it destroys the *child* pool. It doesn't touch
> 'pool' at all.
>
> Therefore, closing the fs isn't going to affect the repos object.
Ahh, thanks (it also goes to Kerl). I stand corrected. (My
brain is not functioning well because I had to wake up early
in the morning to supervise a term end exam of
undergraduate. Funny that I was taking the exam of graduate
course by the same teacher yesterday...)
The commit actually fixed pool usage bug in Svn::Repos#fs
but probably it was a wrong fix. Having parent and child
relationship of pool in different objects is a hairy issue.
You cannot simply destroy parent's pool from finalization
when parent object is garbage collected because there may be
some objects allocated from subpool. All other Svn::Fs*
objects have the same problem. It has been on my TODO list
for quite some time to fix but perhaps now is the good time
to fix them all. I'll investigate it.
--
Yoshiki Hayashi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Greg Stein <gs...@lyra.org>.
On Wed, Feb 06, 2002 at 11:16:10AM +0900, Yoshiki Hayashi wrote:
> Greg Stein <gs...@lyra.org> writes:
>
> > That isn't quite correct. svn_fs_close_fs() only clears/destroys a subpool.
> > It will /not/ affect the pool that you passed in when you created the FS
> > object. It is perfectly safe to call close_fs().
> >
> > > svn_repos_fs returns svn_fs_t * which lives in the same pool
> > > of svn_repos_t *.
> >
> > No... the FS lives in a subpool. That subpool can be independently freed.
>
> Ah, then this is the bug in svn_repos_open?
What bug? Just what exactly are you seeing?
> libsvn_repos/repos.c:
>
> svn_error_t *
> svn_repos_open (svn_repos_t **repos_p,
> const char *path,
> apr_pool_t *pool)
> {
> apr_status_t apr_err;
> svn_repos_t *repos;
>
> /* Allocate a repository object. */
> repos = apr_pcalloc (pool, sizeof (*repos));
> repos->pool = pool;
>
> /* Initialize the repository paths. */
> repos->path = apr_pstrdup (pool, path);
> init_repos_dirs (repos, pool);
>
> /* Initialize the filesystem object. */
> repos->fs = svn_fs_new (pool);
This says to create repos->fs in 'pool'. The FS does so, as a child pool.
When you call close_fs(), it destroys the *child* pool. It doesn't touch
'pool' at all.
Therefore, closing the fs isn't going to affect the repos object.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Yoshiki Hayashi <yo...@xemacs.org>.
Greg Stein <gs...@lyra.org> writes:
> That isn't quite correct. svn_fs_close_fs() only clears/destroys a subpool.
> It will /not/ affect the pool that you passed in when you created the FS
> object. It is perfectly safe to call close_fs().
>
> > svn_repos_fs returns svn_fs_t * which lives in the same pool
> > of svn_repos_t *.
>
> No... the FS lives in a subpool. That subpool can be independently freed.
Ah, then this is the bug in svn_repos_open?
libsvn_repos/repos.c:
svn_error_t *
svn_repos_open (svn_repos_t **repos_p,
const char *path,
apr_pool_t *pool)
{
apr_status_t apr_err;
svn_repos_t *repos;
/* Allocate a repository object. */
repos = apr_pcalloc (pool, sizeof (*repos));
repos->pool = pool;
/* Initialize the repository paths. */
repos->path = apr_pstrdup (pool, path);
init_repos_dirs (repos, pool);
/* Initialize the filesystem object. */
repos->fs = svn_fs_new (pool);
--
Yoshiki Hayashi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Greg Stein <gs...@lyra.org>.
On Wed, Feb 06, 2002 at 10:44:35AM +0900, Yoshiki Hayashi wrote:
> Greg Stein <gs...@lyra.org> writes:
> > > Author: yoshiki
> > > Date: 2002-02-05 13:24 GMT
> > > New Revision: 1186
> > >
> > > Modified:
> > > trunk/subversion/bindings/ruby/fs.c
> > > Log:
> > > * fs.c (free_fs): Do not call svn_fs_close_fs because it will toss pool fs is
> > > allocated. The pool might be also used by Svn::Repos object.
> >
> > How could the Svn::Repos object use a pool that is internal to the svn_fs
> > object? This doesn't make sense to me...
>
> It's other way around. Svn::Fs object is constructed out of
> the pool Svn::Repos is using. It happens when you call
> Svn::Repos#fs, which create Svn::Fs object by calling
> svn_repos_fs function.
That isn't quite correct. svn_fs_close_fs() only clears/destroys a subpool.
It will /not/ affect the pool that you passed in when you created the FS
object. It is perfectly safe to call close_fs().
> svn_repos_fs returns svn_fs_t * which lives in the same pool
> of svn_repos_t *.
No... the FS lives in a subpool. That subpool can be independently freed.
> Documentation of svn_repos_fs says
> nothing about the pool svn_fs_t is allocated but it is safer
> to assume they are using the same pool than they came from
> distinct pools.
Then the documentation should be updated. But even so, there isn't any way
that close_fs could "reach out" and kill somebody else's pool. It does (and
should) only affect its internal storage.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 1186 - trunk/subversion/bindings/ruby
Posted by Yoshiki Hayashi <yo...@xemacs.org>.
Greg Stein <gs...@lyra.org> writes:
> > Author: yoshiki
> > Date: 2002-02-05 13:24 GMT
> > New Revision: 1186
> >
> > Modified:
> > trunk/subversion/bindings/ruby/fs.c
> > Log:
> > * fs.c (free_fs): Do not call svn_fs_close_fs because it will toss pool fs is
> > allocated. The pool might be also used by Svn::Repos object.
>
> How could the Svn::Repos object use a pool that is internal to the svn_fs
> object? This doesn't make sense to me...
It's other way around. Svn::Fs object is constructed out of
the pool Svn::Repos is using. It happens when you call
Svn::Repos#fs, which create Svn::Fs object by calling
svn_repos_fs function.
svn_repos_fs returns svn_fs_t * which lives in the same pool
of svn_repos_t *. Documentation of svn_repos_fs says
nothing about the pool svn_fs_t is allocated but it is safer
to assume they are using the same pool than they came from
distinct pools.
--
Yoshiki Hayashi
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org