While trying to generate a small example that shows the memory corruption problem reported by Steve, I came along these issues:

a) [1] is .Sub, [2] is turned off
   The subroutine prints main's $m - very likely wrong.

Q: Should the Sub get a NULL scratch pad, or a new empty scratch pad stack?

b) [1] is .Closure, [2] is turned off
   The closure prints "main" - probably ok

c) [1] is .Closure, [2] is "newpad 0"
   Lexical '$m' not found

d) [1] is .Closure, [2] is "newpad 1"
   prints "main"

Q: What is correct?

.sub _main
        new_pad 0
        new $P0, .PerlString
        set $P0, "main\n"
        store_lex -1, "$m", $P0
        .sym pmc foo
        newsub foo, .Sub, _foo     # [1]
        .pcc_begin prototyped
        .pcc_call foo
        .pcc_end
        pop_pad
        end
.end
.sub _foo prototyped
        # new_pad 1                # [2]
        find_lex $P0, "$m"
        print $P0
        # pop_pad
        .pcc_begin_return
        .pcc_end_return
.end

leo



Reply via email to