On Sun, Apr 23, 2006 at 02:54:23PM +0300, Niko Tyni wrote:
>The problem AIUI is as follows:
>
>The pkgCacheFile::Packages() function in AptPkg.xs creates a new
>pkgRecords object, which contains a (private) pointer to the pkgCacheFile
>object itself. However, Perl doesn't know this, and the reference count
>of the pkgCacheFile object isn't increased. When the pkgRecords object
>is destroyed, its destructor (inside libapt-pkg) uses the pkgCacheFile
>pointer, and segfaults if the pkgCacheFile object has been destroyed
>earlier.
>
>The trouble in reproducing this is because both the pkgCacheFile and
>the pkgRecords object have the same reference count, so they are
>destroyed in an undefined order.
Thanks Niko, well spotted.
It turns out that there are a number of other cases which exhibit
similar problems. Consider the following [contrived] example:
use AptPkg::Cache;
my $c = AptPkg::Cache->new;
my $p = $c->{bash};
undef $c;
print $p->{Name}, "\n";
I've generalised your change to cover all instances where the parent
object must outlive the child.
--bod
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]