id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	lang	patch	platform
2191	Problems with IMCCompiler PMC	whiteknight		"I've been seeing some weird problems with methods on the IMCCompiler PMC lately. IMCC has never been very friendly with contexts and preserving things across calls, and there have been several optimizations made lately to master that affect PCC.

Here are two files, test1.pir and test2.pir. Compile the second one to test2.pbc. Then, run test1.pir. The result is random. I've seen anything from segfaults and core dumps, to throwing weird exceptions for code that doesn't appear to be in the program. This suggests that the context is screwed up following the call to .'compile'(), and it is attempting to execute a random place in memory.

test1.pir:
{{{
.sub main :main
    say ""test1: main""

    # Works fine
    $P0 = compreg ""PIR""
    say ""test1: compiling""
    $P1 = $P0.'compile'("".sub main :main\nsay 'in compile main'\n.end\n"")

    say ""test1: loading""
    load_bytecode ""test2.pbc""
    $P0 = get_global [""Foo""], ""test""
    $P1 = $P0()
    
    # Never gets here
    $P1()
.end
}}}

test2.pir:
{{{
.namespace [""Foo""]
.sub test
    # This part works
    say ""test2: test""
    $P0 = compreg ""PIR""
    say ""test2: compiling""
    $P1 = $P0.'compile'("".sub main :main\nsay 'in compile main'\n.end\n"")

    # The weirdness starts here.
    say ""test2: compiled""
    $P2 = $P1.'main_sub'()
    .return($P2)
.end
}}}

I'm digging into this issue, but I wanted to create a ticket to help track it. "	bug	closed	normal		imcc	master	medium	fixed					
