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

Re: segmentation fault in python bindings

From: David James <djames_at_collab.net>
Date: 2006-09-03 20:37:27 CEST

On 9/3/06, Thomas Delaet <tdelaet@gmail.com> wrote:
> Hi all,
>
> Before creating a ticket, I would like to check if I did not do
> something stupid. The following snippet of code gives me a
> segmentation fault on my Ubuntu 6.06 system (subversion version 1.3.1
> (r19032)).
>
> #!/usr/bin/python
>
> import svn.repos
> import svn.core
>
> svn.core.apr_initialize()
> pool = svn.core.svn_pool_create(None)
>
> fs_config = { "fs-type": "fsfs" }
> #fs_config = None
>
> i = 0
>
> index = {}
>
> while i < 99:
> print i
> index[str(i)] = svn.repos.svn_repos_create("test" +
> str(i),"","",None,fs_config,pool)
> i += 1
>
> svn.core.svn_pool_destroy(pool)
> svn.core.apr_terminate()
>
> The output of this code snippet is:
>
> 0
> 1
> 2
> Segmentation fault
>
> When I set fs_config to None, it works perfectly. Thing is that I need
> to create a fsfs type repository.
>
> I tried re-arranging the apr and pool commands, assigning the
> repository pointer to the same variable (only one repository is
> created in this case) and just executing the create command without
> assigning the result to a variable.
>
> Anyone got a clue?
>
> Tnx in advance,
>
> Kind Regards,
> --
> Thomas

Hi Thomas,

Thanks for the bug report, and excellent reproduction script! This
looks like a reference-counting bug in
svn_swig_py_stringhash_from_dict. In these functions, we grab borrowed
references using PyList_GetItem and PyDict_GetItem. When we are done
with the borrowed reference, we decrement the reference count of the
returned object. This is incorrect.

You can fix this bug by taking out the unnecessary calls to
Py_DECREF(key) and Py_DECREF(value) in
svn_swig_py_stringhash_from_dict in swigutil_py.c.

There's no need to file an issue. I'll take a look at this in more
detail next week, and submit a patch and a test case.

Hope this helps,

David

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Sep 3 20:38:01 2006

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.