Ticket #1886 (assigned bug)

Opened 4 years ago

Last modified 3 years ago

set_string_native() not implemented in class 'TclString'

Reported by: coke Owned by: whiteknight
Priority: critical Milestone:
Component: none Version: master
Severity: fatal Keywords:
Cc: Language: tcl
Patch status: Platform:

Description

This error has cropped up in the last few months in partcl-nqp. (No changes in partcl, just upgrading parrot was sufficient to gen the error)

In one case, there was a concat operation in our src/Partcl/commands/time.pm ; prefixing the first element with a ~ avoided the error. (but should have been unnecessary.)

There is another location where this error occurs, triggered by the following tcl:

$ cat error.tcl
for {set i 0} {$i < 2} {set i [expr $i+1]} {puts $i}
$ ./partcl error.tcl
0
1
set_string_native() not implemented in class 'TclString'
    while executing
eval
    (file "<unknown file>" line 7)
for
    (file "<unknown file>" line 12)
HLL::Compiler::eval
    (file "<unknown file>" line 151)
PCT::HLLCompiler::evalfiles
    (file "<unknown file>" <unknown line>)
PCT::HLLCompiler::command_line
    (file "<unknown file>" <unknown line>)
main
    (file "<unknown file>" line 1)

In eval (src/Partcl/commands/eval.pm) the error is occurring when invoking the sub generated by:

my &sub := Partcl::Compiler.compile($code);
&sub(); #BOOM

In any case, TclString should in fact have a set_string_native, inherited from its parent class of String; it's declared in an nqp file as:

class TclString is String

Change History

  Changed 3 years ago by coke

This is causing partcl-nqp's t/cmd_for.t to fail.

  Changed 3 years ago by coke

I just ran a bisect on t/cmd_for.t using latest par

It says:

cf6e9a458ea5ad9238739acf3fef07cca3d3524a is the first bad commit commit cf6e9a458ea5ad9238739acf3fef07cca3d3524a Author: Gerd Pokorra <pokorra@…> Date: Tue Oct 19 08:31:46 2010 +0000

update to 2.9.0

git-svn-id:  https://svn.parrot.org/parrot/trunk@49575 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

  Changed 3 years ago by coke

whoops. "*using latest partcl, and just bisecting on parrot.

  Changed 3 years ago by coke

This is the last remaining blocker for partcl-nqp. (All other tests now pass.)

  Changed 3 years ago by coke

  • severity changed from medium to high

  Changed 3 years ago by coke

Unrolling the for loop, here's some tcl code that also demonstrates the issue:

set i 1
set i [expr $i+1]
puts $i
set i [expr $i+1]
puts $i

(should print 2\n3\n)

however, THIS code works:

set i 1
set i [expr $i +1]
puts $i
set i [expr $i +1]
puts $i

  Changed 3 years ago by whiteknight

  • owner set to whiteknight
  • priority changed from normal to critical
  • status changed from new to assigned
  • severity changed from high to fatal

Here's the backtrace I get from the failure:

#0  Parrot_ex_throw_from_c_args (interp=0x79f040, ret_addr_unused=0x0, exitcode=36, 
    format=0x7ffff7b2ffe0 "%s() not implemented in class '%Ss'") at src/exceptions.c:440
#1  0x00007ffff79fd18d in cant_do_method (interp=0x79f040, pmc=0xa54c10, index=168)
    at /home/andrew/projects/parrot/./src/pmc/default.pmc:148
#2  0x00007ffff79fd93e in Parrot_default_set_string_native_orig (interp=0x79f040, _self=0xa54c10, 
    value=0x9d1158) at /home/andrew/projects/parrot/./src/pmc/default.c:2602
#3  0x00007ffff79fa505 in Parrot_default_set_string_native (interp=0x79f040, _self=0xa54c10, 
    value=0x9d1158) at /home/andrew/projects/parrot/./src/pmc/default.c:1862
#4  0x00007ffff7a25d0a in Parrot_Float_set_string_native_orig (interp=0x79f040, _self=0xa54c10, 
    value=0x9d1158) at /home/andrew/projects/parrot/./src/pmc/float.pmc:181
#5  0x00007ffff7a224c5 in Parrot_Float_set_string_native (interp=0x79f040, _self=0xa54c10, 
    value=0x9d1158) at /home/andrew/projects/parrot/./src/pmc/float.c:364
#6  0x00007ffff7acf4eb in Parrot_scalar_concatenate_str (interp=0x79f040, _self=0x914bf8, 
    value=0xd91fb0, dest=0xa54c10) at /home/andrew/projects/parrot/./src/pmc/scalar.pmc:648
#7  0x00007ffff7934196 in Parrot_concat_p_p_sc (cur_opcode=0xb037a8, interp=0x79f040)
    at src/ops/core_ops.c:20122
#8  0x00007ffff79ce688 in runops_fast_core (interp=0x79f040, runcore_unused=0x881300, pc=0xb037a8)
    at src/runcore/cores.c:513
#9  0x00007ffff79cdb0b in runops_int (interp=0x79f040, offset=113807) at src/runcore/main.c:218
#10 0x00007ffff7992325 in runops (interp=0x79f040, offs=113807) at src/call/ops.c:126
#11 0x00007ffff798a6ad in Parrot_pcc_invoke_from_sig_object (interp=0x79f040, sub_obj=0x9cf288, 
    call_object=0xd8e700) at src/call/pcc.c:323
#12 0x00007ffff798a4d2 in Parrot_pcc_invoke_sub_from_c_args (interp=0x79f040, sub_obj=0x9cf288, 
    sig=0x7ffff7b343cb "P->") at src/call/pcc.c:130
#13 0x00007ffff79e6309 in Parrot_pf_execute_bytecode_program (interp=0x79f040, pf=0x89d890, 
    args=0x8905c0) at src/packfile/api.c:4523
#14 0x00007ffff795d8db in Parrot_api_run_bytecode (interp_pmc=0x873af8, pbc=0x9da358, 
    mainargs=0x8905c0) at src/embed/api.c:457
#15 0x0000000000400f68 in main ()

I need to do some digging, but it appears on quick inspection that this is an MMD-related failure inside scalar.concatinate_str.

  Changed 3 years ago by whiteknight

Okay, I've figured out what the problem is. I've created the whiteknight/tt_1886 branch to fix it.

In the example, we're calling Parrot_pmc_reuse to convert a Float to a TclString (which is an Object). However, that codepath has undefined behavior. Parrot_pmc_reuse includes a comment suggesting that we should not use it with Objects. Coming back from Parrot_pmc_reuse, the new TclString PMC has a bad vtable structure. When we try to call set_string_native, we go to the wrong vtable and throw the exception.

In the tt_1886 branch I'm going to refactor some of the instantiation logic out of the Class PMC into src/oo.c. Then I'm going to use that logic to implement the proper codepath in Parrot_pmc_reuse to handle the case of morphing to an Object type.

follow-up: ↓ 10   Changed 3 years ago by whiteknight

I don't see that branch around anymore, and I didn't keep any records about whether I ever merged it or not.

Coke: Can you see if this is still an issue or not?

in reply to: ↑ 9   Changed 3 years ago by coke

Replying to whiteknight:

I don't see that branch around anymore, and I didn't keep any records about whether I ever merged it or not. Coke: Can you see if this is still an issue or not?

No change.

Note: See TracTickets for help on using tickets.