Subject: | weak sets cause an error on the next statement when an element's reference count is reduced to 0 |
The following program causes the error "# (Object.xs:441): Set::Object magic backref hook called on non-existent item (0x9648088, self = 0x9664868) at set-object-weak-test-4.pl line 11." when run; additionally, when various other trivial changes are made (such as creating two sets and adding $a to both, rather than one, or repeating the "print" line twice more), Perl segfaults.
use Set::Object qw/weak_set/;
my $a;
{
my $n = 1;
$a = \$n;
}
bless $a, "strict"; # bless it so it can be added to the set without segfaulting, the package is irrelevant
my $set1 = weak_set();
$set1->insert($a);
$a = undef;
print "Test\n"; # for some reason this line is needed to trigger the error
The error seems to happen on the statement after the object's reference count is reduced to 0. Expected behaviour is for the object to be removed from the set when its reference count becomes 0 (just like any other sort of weak reference becomes undefined when the object's reference count is reduced to 0), with no error.
Importance set to "important" given that the whole point of using weak references is that you expect that the reference count might potentially go to 0.
Tested on Set::Object version 1.27, Perl version 5.10.0 running on Linux (2.6.31-17; packaged with Ubuntu Karmic).
use Set::Object qw/weak_set/;
my $a;
{
my $n = 1;
$a = \$n;
}
bless $a, "strict"; # bless it so it can be added to the set without segfaulting, the package is irrelevant
my $set1 = weak_set();
$set1->insert($a);
$a = undef;
print "Test\n"; # for some reason this line is needed to trigger the error
The error seems to happen on the statement after the object's reference count is reduced to 0. Expected behaviour is for the object to be removed from the set when its reference count becomes 0 (just like any other sort of weak reference becomes undefined when the object's reference count is reduced to 0), with no error.
Importance set to "important" given that the whole point of using weak references is that you expect that the reference count might potentially go to 0.
Tested on Set::Object version 1.27, Perl version 5.10.0 running on Linux (2.6.31-17; packaged with Ubuntu Karmic).