Skip Menu |

This queue is for tickets about the Set-Object CPAN distribution.

Report information
The Basics
Id: 53181
Status: rejected
Priority: 0/
Queue: Set-Object

People
Owner: Nobody in particular
Requestors: ais523 [...] bham.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.27
Fixed in: (no value)



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).
On Mon Dec 28 07:54:56 2009, ais523 wrote: Show quoted text
> 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).
Thanks for reporting this; any chance you can knock up a failing test case against http://github.com/samv/Set-Object and send a pull request? I'm a bit busy ... Cheers, Sam.
I'm currently not accepting bug reports without TAP compliant test cases, sorry.