Skip to content

Commit

Permalink
Segfault in very esoteric corner case (root cause perl5 bug)
Browse files Browse the repository at this point in the history
I nailed it down, though I don't think this warrants any fixing on the XSA
part. The committed test fails on everything < 5.8.9. It appears to be caused
by this: http://rt.perl.org/rt3/Public/Bug/Display.html?id=35878

The only reason I proceeded writing a full test is that the *first* pass seems
to work, so It may be something relatively easy to fix in the guts of XSA.

If you are wondering why someone would be doing so much hackery when all we
want are quick accessors see lines 99~122:
http://dev.catalystframework.org/svnweb/bast/revision?rev=9746
  • Loading branch information
ribasushi committed Oct 11, 2010
1 parent 4bfbcfe commit 8fe9c12
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions t/50reentrant_goto_sigsegv.t
@@ -0,0 +1,53 @@
use strict;
use warnings;

use Class::XSAccessor;
use Test::More;

my $shim_calls;

sub install_accessor_with_shim {
my ($class, $name, $field) = @_;

$field = $name if not defined $field;

Class::XSAccessor->import ({
class => $class,
getters => { $name => $field },
replace => 1,
});

my $xs_cref = $class->can ($name);

no strict 'refs';
no warnings 'redefine';

*{"${class}::${name}"} = sub {
$shim_calls++;
goto $xs_cref;
};
}

for my $name (qw/bar baz/) {
for my $pass (1..2) {

$shim_calls = 0;

install_accessor_with_shim ('Foo', $name);
my $obj = bless ({ $name => 'a'}, 'Foo');

is ($shim_calls, 0, "Reset number of calls ($name pass $pass)" );
is ($obj->$name, 'a', "Accessor read works ($name pass $pass)" );
is ($shim_calls, 1, "Shim called ($name pass $pass)" );

eval { $obj->$name ('ack!') };
ok ($@ =~ /Usage\: $name\(self\)/, "Exception from R/O accessor thrown ($name pass $pass)" );
is ($shim_calls, 2, "Shim called anyway ($name pass $pass)" );

eval { $obj->$name ('ick!') };
ok ($@ =~ /Usage\: $name\(self\)/, "Exception from R/O accessor thrown once again ($name pass $pass)" );
is ($shim_calls, 3, "Shim called again ($name pass $pass)" );
}
}

done_testing;

0 comments on commit 8fe9c12

Please sign in to comment.