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

Ctypes-python Array class self-reference problem

From: Julian Foad <julian.foad_at_wandisco.com>
Date: Mon, 15 Aug 2011 17:39:55 +0100

For anyone interested: I'm trying to debug a memory problem in the
ctypes-python bindings Array class which models an apr_array_header_t
array. I suppose this class may never have worked properly, as it gets
exercised very little within the bindings and had no unit test cases
until today.

Running within its test suite it mostly works, but there appears to be a
problem in making a deep copy of, or holding onto a reference to, each
element when a new array is initialized.

A simple demonstration in the Python interpreter:

$ (cd subversion/bindings/ctypes-python/ && python -i
>>> from csvn.core import *
>>> from csvn.types import Array
>>> a1 = Array(c_char_p, ['one'])
>>> a1

The last line should have shown "Array(['one'])", but it printed garbage
from the Python interpreter's memory. This is so bad that I wonder if
my expectations are wrong.

The attached patch contains various changes and additions that I tried
unsuccessfully, and it adds tests that all pass (for me) except for the
places where they extend an Array with another (or the same) array.
Initially I thought the problem was only with self-referencing, because
I saw the failures in expressions such as "a1.extend(a1)", but now I am
noticing the same effect more widely.

Any hints appreciated.

- Julian

Received on 2011-08-15 18:40:31 CEST

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.