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

Re: More info on Swig 1.31 vs 1.33

From: Kouhei Sutou <kou_at_cozmixng.org>
Date: Thu, 31 Jan 2008 13:32:58 +0900

Hi,

2008/1/30, Peter Samuelson <peter_at_p12n.org>:

> %typemap(ruby, argout) apr_pool_t *pool
> {
> svn_swig_rb_set_pool($result, _global_svn_swig_rb_pool);
> svn_swig_rb_pop_pool(_global_svn_swig_rb_pool);
> }
>
> This isn't really output parameter processing (hint: it doesn't
> assign to $result), it is merely abusing an argout typemap
> to apply some final processing AFTER all "real"
> output parameters have been processed (and accumulated
> in $result), but BEFORE the final "return $result".
> This works since apr_pool_t* parameters
> are generally the last parameter in SVN and APR functions.
>
> Note that this approach is rather specific to Ruby. Python does
> the equivalent processing in a freearg typemap (line 319).
> (freearg typemap code is emitted at roughly the same place
> as the code for the final argout parameter.)
> But Ruby probably can't just switch to a freearg typemap,
> because it requires access to $result which isn't available
> in freearg typemaps (though I don't understand what
> svn_swig_rb_set_pool does with $result).

This is for GC. The ruby bindings create a pool for each method call.
The pool is owned (referenced) by $result not self. If self ownes the pool,
the pool is never GCed until self is GCed even if $result that uses memory
in the pool is GCed. If $result ownes the pool, the pool will be GCed when
$result is GCed even if self isn't GCed.

Solution:
1) use 'vresult' instead of $result. :<
2) ask for reverting the SWIG change and mark SWIG 1.3.33 as 'not supported'.
3) come up with any other implementation idea.

Thanks,

--
kou
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-01-31 05:33:08 CET

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