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

Re: Tracking pool ownership for struct members in the Python bindings

From: David James <james82_at_gmail.com>
Date: 2005-09-26 02:00:50 CEST

On 9/23/05, David James <james82@gmail.com> wrote:
> Currently, the Python bindings track pool ownership on a per-object
> basis. This technique works great in most situations, but there are a
> few edge cases. See r16233 for an example. Here's a short test case.
>
> Test Script
> =============
> import svn.core
> import svn.client
> client_ctx = svn.client.svn_client_create_context()
> config = svn.core.svn_config_get_config(None)
> client_ctx.config = config
> providers = [
> svn.client.svn_client_get_simple_provider()
> ]
> auth_baton = svn.core.svn_auth_open(providers)
> client_ctx.auth_baton = auth_baton
> head_rev = svn.core.svn_opt_revision_t()
> head_rev.kind = svn.core.svn_opt_revision_head
> print svn.client.ls("http://svn.collab.net/repos/svn/trunk",head_rev, 0,
> client_ctx)
> del config
> del auth_baton
> print "Get ready for a segfault..."
> print svn.client.ls("http://svn.collab.net/repos/svn/trunk",head_rev, 0,
> client_ctx)
> =============
>
> Result: segfault. Here's why: client_ctx.config and
> client_ctx.auth_baton are struct members of client_ctx, and therefore
> don't have any space to store references to their created pools. So,
> when you delete the "config" and "auth_baton" objects, their pools get
> garbage collected, and the client_ctx.config and client_ctx.auth_baton
> objects are silently invalidated. Thus, when you run svn.client.ls,
> you get a segfault.
>
> Any suggestions on how I can fix this?
>
> Here's a shorter example, which also crashes:
> =============
> import svn.core
> import svn.client
> client_ctx = svn.client.svn_client_create_context()
> client_ctx.config = svn.core.svn_config_get_config(None)
> providers = [
> svn.client.svn_client_get_simple_provider()
> ]
> client_ctx.auth_baton = svn.core.svn_auth_open(providers)
> head_rev = svn.core.svn_opt_revision_t()
> head_rev.kind = svn.core.svn_opt_revision_head
> print "Get ready for a segfault..."
> print svn.client.ls("http://svn.collab.net/repos/svn/trunk",head_rev, 0,
> client_ctx)
> =============

I've upgraded the Python bindings to track pool ownership of struct
members in r16248 and r16249. So, the above test cases now work!

Cheers,

David

--
David James -- http://www.cs.toronto.edu/~james
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Sep 26 02:03:01 2005

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.