Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_string_native() not implemented in class 'TclString' #448

Open
coke opened this issue Dec 11, 2010 · 12 comments
Open

set_string_native() not implemented in class 'TclString' #448

coke opened this issue Dec 11, 2010 · 12 comments

Comments

@coke
Copy link
Contributor

coke commented Dec 11, 2010

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

Originally http://trac.parrot.org/parrot/ticket/1886

@coke
Copy link
Contributor Author

coke commented Feb 13, 2011

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

@coke
Copy link
Contributor Author

coke commented Feb 13, 2011

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

It says:

cf6e9a4 is the first bad commit commit cf6e9a4 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

@coke
Copy link
Contributor Author

coke commented Feb 13, 2011

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

@coke
Copy link
Contributor Author

coke commented Mar 7, 2011

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

@coke
Copy link
Contributor Author

coke commented Mar 7, 2011

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

@Whiteknight
Copy link
Contributor

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.

@Whiteknight
Copy link
Contributor

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.

@Whiteknight
Copy link
Contributor

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?

@coke
Copy link
Contributor Author

coke commented Oct 20, 2011

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.

@leto
Copy link
Member

leto commented Dec 12, 2012

Can this issue be closed?

@coke
Copy link
Contributor Author

coke commented Dec 12, 2012

No. Still no change, going on 2 years.

@leto
Copy link
Member

leto commented Dec 12, 2012

@Whiteknight I don't think the whiteknight/tt_1886 ever got pushed to SVN, because it does not currently exist as a branch and it was not merged in at any point in our Git history. Any chance you can find that branch or reimplement?

@Whiteknight Whiteknight removed their assignment Mar 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants