[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
blead and Glib's lazy-loader
Aloha,
it looks like current bleadperl breaks Glib's lazy-loading scheme. This
happened once before with perl 5.10:
<http://markmail.org/message/dp27effje5arxgsc>. The problem then was that we
called av_clear on an @ISA array, which broke mro's idea of the hierarchy. We
switched to using av_shift repeatedly to fix this.
The current code (which works with perl 5.8 and perl 5.10 but breaks with blead)
basically looks like this[1]:
AV * isa = get_av("Some::ISA", FALSE);
AV * new_isa = newAV ();
for (i = 0 ; i < av_len (isa) + 1 ; i++) {
SV * sv = av_shift (isa);
...
av_push (new_isa, "Something");
sv_free (sv);
}
for (i = 0 ; i < av_len (new_isa) ; i++) {
SV ** svp = av_fetch (new_isa, i, FALSE);
av_push (isa, SvREFCNT_inc (*svp));
}
av_clear (new_isa);
av_undef (new_isa);
This code is invoked whenever isa() or similar is called on a package which is
set up for lazy-loading. It seems that this time, the code only breaks when
there are multiple layers of inheritance: the attached lazy-test-v3-good.pl
works fine even with blead, whereas lazy-test-v3.pl breaks with blead (but works
fine with perl 5.8 and 5.10).
Does anyone have any insights?
-Torsten
[1] The full code is in <http://search.cpan.org/src/TSCH/Glib-1.200/GObject.xs>,
function class_info_finish_loading. The failing test is
<http://search.cpan.org/src/TSCH/Glib-1.200/t/lazy-loader.t>.
#!/usr/bin/perl
use strict;
use warnings;
use Glib;
@Foo::ISA = qw(Glib::InitiallyUnowned);
dump_hierarchy (Foo::);
warn Foo->isa('Glib::Object');
dump_hierarchy (Foo::);
warn Foo->isa('Glib::Object');
# force the lazy loader to setup the hierarchy
my $object = Glib::InitiallyUnowned->new ();
sub dump_hierarchy {
my ($package, $indent) = @_;
$indent ||= 0;
print ' ' x $indent, $package, "\n";
no strict 'refs';
foreach my $parent (@{$package . '::ISA'}) {
dump_hierarchy ($parent, $indent + 2);
}
}
#!/usr/bin/perl
use strict;
use warnings;
use Glib;
dump_hierarchy (Glib::InitiallyUnowned::);
warn Glib::InitiallyUnowned->isa('Glib::Object');
dump_hierarchy (Glib::InitiallyUnowned::);
warn Glib::InitiallyUnowned->isa('Glib::Object');
# force the lazy loader to setup the hierarchy
my $object = Glib::InitiallyUnowned->new ();
sub dump_hierarchy {
my ($package, $indent) = @_;
$indent ||= 0;
print ' ' x $indent, $package, "\n";
no strict 'refs';
foreach my $parent (@{$package . '::ISA'}) {
dump_hierarchy ($parent, $indent + 2);
}
}
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]