Skip to content

Commit

Permalink
Fix "Attempt to free unreferenced scalar" in shutdown
Browse files Browse the repository at this point in the history
When the Perl 5 interpreter has been shut down, we may no longer call
SvREFCNT_dec on any objects. Fix Perl5Hash and Perl5Array destructors
to do the same as Perl5Object's which is to use Inline::Perl5::sv_refcnt_dec
method which checks whether the interpreter is still running.
  • Loading branch information
niner committed Oct 21, 2016
1 parent 431344a commit 045a0d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Inline/Perl5.pm6
Expand Up @@ -431,7 +431,7 @@ my class Perl5Hash does Iterable does Associative {
p5_sv_refcnt_inc($!p5, $!hv);
}
submethod DESTROY() {
p5_sv_refcnt_dec($!p5, $!hv);
$!ip5.sv_refcnt_dec($!hv);
}
method ASSIGN-KEY(Perl5Hash:D: Str() \key, Mu \assignval) is raw {
p5_hv_store($!p5, $!hv, key, $!ip5.p6_to_p5(assignval));
Expand Down Expand Up @@ -529,7 +529,7 @@ my class Perl5Array does Iterable does Positional {
submethod BUILD(:$!ip5, :$!p5, :$!av) {
}
submethod DESTROY() {
p5_sv_refcnt_dec($!p5, $!av);
$!ip5.sv_refcnt_dec($!av);
}
method ASSIGN-POS(Perl5Array:D: Int() \pos, Mu \assignval) is raw {
p5_av_store($!p5, $!av, pos, $!ip5.p6_to_p5(assignval));
Expand Down

0 comments on commit 045a0d5

Please sign in to comment.