Ticket #802 (new bug)

Opened 5 years ago

Last modified 3 years ago

freeze opcode segfaults on working bytecode from Rakudo

Reported by: mberends Owned by: whiteknight
Priority: normal Milestone:
Component: core Version: 1.3.0
Severity: medium Keywords: parrot perl6 freeze
Cc: martin.berends@… Language: perl6
Patch status: Platform: linux

Description

The following compiles bytecode from PIR and perl6 source strings and verifies that a subroutine works in both cases. The PIR example can be frozen (and thawed in other tests) but the perl6 example causes freeze to segfault. Tested only on linux/amd64. Fixing this would be assist a project to build a versioned module database for Rakudo (Synopsis 11).

# freeze-test.pir
# Assumes parrot was installed by Rakudo's Configure --gen-parrot
# - edit the load_bytecode line otherwise.

.sub 'testmain' :main
    .local string testPIRsource
    testPIRsource = <<'    testPIRsource_end'
        .sub test_PIR
            .param string x
            .local string result
            result = 'test PIR '
            result .= x
            .return ( result )
        .end
    testPIRsource_end
    .local pmc PIRcompiler, testPIRbytecode, parrotnamespace, test_PIR
    PIRcompiler = compreg 'PIR' # parrot/docs/pdds/draft/pdd06_pasm.pod
    testPIRbytecode = PIRcompiler( testPIRsource )
    parrotnamespace = get_root_namespace [ 'parrot' ]
    test_PIR = parrotnamespace.'find_sub' ('test_PIR')
    $S0 = test_PIR ( '10 b' ) # execute the generated bytecode
    print $S0
    say ' PIR code compiled, ready to be frozen'

    .local string testP6source
    testP6source = <<'    testP6source_end'
        sub test_P6 ( Str $x ) {
            return "test P6 $x";
        }
    testP6source_end
    # the next line assumes rakudo configured with --gen-parrot
    load_bytecode '../perl6.pbc' # adjust directory if different
    .local pmc P6compiler, testP6bytecode, P6namespace, test_P6
    # see similar code in .sub 'eval' in rakudo/src/builtins/control.pir
    P6compiler = compreg 'perl6'
    testP6bytecode = P6compiler.'compile' ( testP6source )
    P6namespace = get_root_namespace [ 'perl6' ]
    test_P6 = P6namespace.'find_sub' ('test_P6')
    $S0 = test_P6 ( '10 c' )
    print $S0
    say ' Perl 6 code compiles, ready to be frozen'

    .local string frozenPIR, filename
    frozenPIR = freeze testPIRbytecode
    filename  = "/tmp/bytecode_from_PIR.frozen"
    .local pmc filehandle
    filehandle = open filename, "w"
    print filehandle, frozenPIR
    close filehandle
    $I0 = stat filename, 1 # 1 means get file size
    print $I0
    say ' bytes frozen from PIR'

    .local string frozenP6
# Uncomment the next line to see the problem
#   frozenP6 = freeze testP6bytecode            # segfaults
    filename  = "/tmp/bytecode_from_P6.frozen"
    filehandle = open filename, "w"
    print filehandle, frozenP6
    close filehandle
    $I0 = stat filename, 1 # 1 means get file size
    print $I0
    say ' bytes frozen from Perl 6'

.end

# Original problem encountered in:
# http://gitorious.org/parrot-module-lib/main/blobs/master/t/10-make-bytecode.t

Change History

  Changed 5 years ago by Infinoid

  • patch new deleted

follow-up: ↓ 4   Changed 4 years ago by whiteknight

  • owner set to whiteknight

  Changed 4 years ago by moritz

When I add a .loadlib 'io_ops', with parrot RELEASE_2_11_0-478-gd69dbbc I get

test PIR 10 b PIR code compiled, ready to be frozen
Null PMC access in invoke()
current instr.: 'testmain' pc 75 (foo.pir:41)

in reply to: ↑ 2   Changed 3 years ago by jkeenan

Replying to whiteknight:

whiteknight,

Could we get an update on the status of this ticket?

Thank you very much.

kid51

Note: See TracTickets for help on using tickets.