Ticket #2191 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

Problems with IMCCompiler PMC

Reported by: whiteknight Owned by:
Priority: normal Milestone:
Component: imcc Version: master
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

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.

Change History

in reply to: ↑ description   Changed 3 years ago by plobsing

Replying to whiteknight:

Should be fixed by 65669fd. interp->current_pf and interp->code had become de-synched, leading to interp->code being incorrectly restored by imcc.

  Changed 3 years ago by whiteknight

  • status changed from new to closed
  • resolution set to fixed

This is indeed fixed. Thanks!

I'll see if I can put together a concise test case somewhere.

Note: See TracTickets for help on using tickets.