# New Ticket Created by Bob Rogers # Please include the string: [perl #38284] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=38284 >
This fixes Closure:mark, which incorrectly assumed that sub->outer_ctx existed if sub->outer_sub did. -- Bob Rogers http://rgrjr.dyndns.org/
Index: src/pmc/closure.pmc =================================================================== --- src/pmc/closure.pmc (revision 11268) +++ src/pmc/closure.pmc (working copy) @@ -58,10 +58,10 @@ void mark () { struct Parrot_sub * sub = PMC_sub(SELF); SUPER(); - if (sub->outer_sub) { + if (sub->outer_sub) pobject_lives(INTERP, (PObj*)sub->outer_sub); + if (sub->outer_ctx) mark_context(INTERP, sub->outer_ctx); - } } Index: t/pmc/closure.t =================================================================== --- t/pmc/closure.t (revision 11268) +++ t/pmc/closure.t (working copy) @@ -33,6 +33,25 @@ ok 1 OUT +pir_output_is(<<'CODE', <<'OUTPUT', 'Make sure we can sweep closures.'); +## This is a regression test for a bug in which Closure:mark expected +## sub->outer_ctx to be initialized, regardless of whether the closure +## had ever been called. +.sub _test_1 :main + .lex "X", $P40 + $P40 = new Integer + $P40 = 22 + .const .Sub $P43 = "___internal_test_1_0_" + newclosure $P44, $P43 + sweep 1 + print "We lived.\n" +.end +.sub ___internal_test_1_0_ :outer('_test_1') + print "This is never actually run.\n" +.end +CODE +We lived. +OUTPUT # remember to change the number of tests :-) -BEGIN { plan tests => 1; } +BEGIN { plan tests => 2; }