Ticket #132 (new bug)

Opened 13 years ago

Last modified 12 years ago

Can't thaw a Sub (or a PIR subclass of a Sub)

Reported by: coke Owned by: plobsing
Priority: normal Milestone:
Component: core Version:
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

Code:

.sub main :main

  $P0 = get_class 'Sub'
  $P1 = subclass $P0, 'myProc'

  .local pmc pirC
  pirC = compreg 'PIR'

  .local string code
  code = <<"END_CODE"

.sub bar
  say "hi"
.end
END_CODE

  .local pmc compiled
  compiled = pirC(code)
  compiled = compiled[0] # just want the first executable sub here.

  compiled() # works

  .local pmc sub
  sub = new 'myProc'
  assign sub, compiled
  sub() # works

  $S0 = freeze sub
  say "frozen"
  $P2 = thaw $S0
  say "thawed"
  $P2()
.end

Output:

hi
hi
frozen
Unsupported key type in Key.thaw
current instr.: 'main' pc 48 (borked.pir:30)

I'd expect to be able to thaw this PMC, and then invoke the sub after thaw.

Change History

  Changed 13 years ago by jkeenan

  • component changed from none to core

  Changed 12 years ago by bacek

Now it's failing in with different message. Reassign to plobsing as "Image Master" :)

bacek@fireball:~/src/parrot$ ./parrot tt.pir 
hi
hi
frozen
src/pmc/imageio.c:287: failed assertion 'id - 1 == VTABLE_elements(interp, PARROT_IMAGEIO(info)->todo)'
Backtrace - Obtained 18 stack frames (max trace depth is 32).
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b3929f2c]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0(Parrot_confess+0x29) [0x7fc4b38cdb4f]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b39f28ba]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b39f3713]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b3a0f0c0]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b3960f6f]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b39f3549]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0(Parrot_thaw+0x49) [0x7fc4b39613a9]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b3901a15]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b3962be1]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b396219d]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0 [0x7fc4b393af2a]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0(Parrot_pcc_invoke_from_sig_object+0xb1) [0x7fc4b3936d31]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0(Parrot_pcc_invoke_sub_from_c_args+0xeb) [0x7fc4b3936e6b]
/home/bacek/src/parrot/blib/lib/libparrot.so.2.3.0(imcc_run+0x5bc) [0x7fc4b3a4522c]
./parrot [0x4018c6]
/lib/libc.so.6(__libc_start_main+0xfd) [0x7fc4b15caabd]
./parrot [0x401219]
Aborted

follow-up: ↓ 4   Changed 12 years ago by bacek

  • owner set to plobsing

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

Replying to bacek: The problem is that the automagically generated vtable methods in object (where are they comming from?) are wrong for freeze and thaw (remove Object.{freeze,thaw} dummies and watch the fireworks for proof).

I've hidden the associated freeze vtable in r46511, which gets the test a little further.

For example, they depend on self->_class being defined, but no PMCs are guarranteed to exist until thawfinish.

I'm willing to work on the issue, but I'll probably need some help from people familiar with the deep magic involved in parrot pmcproxied objects.

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

  • summary changed from Can't thaw PIR subclass of a Sub to Can't thaw a Sub (or a PIR subclass of a Sub)

Replying to coke:

It appears that not even a Sub proper can be thawed (likely because Subs aren't first class citizens as far as PBC is concerned).

Code:

.sub main :main
  .local pmc pirC
  pirC = compreg 'PIR'

  .local string code
  code = <<"END_CODE"

.sub bar
  say "hi"
.end
END_CODE

  .local pmc compiled
  compiled = pirC(code)
  .local pmc sub
  sub = compiled[0] # just want the first executable sub here.
  sub() # works

  $S0 = freeze sub
  say "frozen"
  $P2 = thaw $S0
  say "thawed"
  $P2()
.end

Output:

hi
frozen
thawed
zsh: segmentation fault  ./parrot test2.pir
Note: See TracTickets for help on using tickets.