Overview
| Artifact ID: | 12dbf84abc28246ea9e4fb92cacb754f7ef0db0f5d4e6a97445de9ff0b285826 |
|---|---|
| Ticket: | 9bdd5788e370acc24ddc8a57e5291832aada8e6b
TCL 8.6.8 does not work with Tcl_SetCommandInfo on some commands |
| User & Date: | sebastianb on 2018-11-19 09:16:33 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
I'm trying to do something non-standard with TCL 8.6.8 that was working just fine with 8.5.12. Actually i want to rewrite proc/objProc for *every* command in every namespace. Since tracing seems to be slower, this solution was used in production code without issues. Basically I'm using Tcl_SetCommandInfo with proc/objProc pointing to my functions that do proxy call to original functions. Bu it was broken in 8.6.8. Some functions, that are (I'm guessing now) native byte code implemented, does not work at all as expected. Instead of calling my proc/objProc I'm getting original behavior of command, my functions are not called at all. Also, touching objClientData field generates assertion (broken byte code). Since this seems fatal for me, and I cannot find any sane solution, there is minimal example that generates assertion in byte code interpreter: #include "tcl.h" #include <string> #include <iostream> #include <assert.h> int objProxy( ClientData clientData, Tcl_Interp *interp, int objc, struct Tcl_Obj *const *objv ) { assert( !"not executed at all" ); return TCL_OK; } int proxy( ClientData clientData, Tcl_Interp *interp, int argc, CONST84 char *argv[] ) { assert( !"not executed at all" ); return TCL_OK; } void doProxy( std::string const& _name, Tcl_Interp* _interp ) { Tcl_CmdInfo commandInfo; int a; commandInfo.isNativeObjectProc = 0; commandInfo.objClientData = &a; /// <---- important to trigger assertion commandInfo.objProc = objProxy; commandInfo.clientData = nullptr; commandInfo.proc = proxy; commandInfo.deleteData = nullptr; commandInfo.deleteProc = nullptr; Tcl_SetCommandInfo( _interp, _name.c_str(), &commandInfo ); } int main() { std::string command( "::tcl::clock::seconds" ); auto interp = Tcl_CreateInterp(); doProxy( command, interp ); Tcl_RecordAndEval( interp, command.c_str(), TCL_EVAL_GLOBAL ); std::cout << Tcl_GetStringResult( interp ) << std::endl; Tcl_DeleteInterp( interp ); return 0; } Example exits with assertion: "clockRead instruction with unknown clock#", debugging tcl internals shows garbage instead of proper byte code. In case commandInfo.objClientData is nullptr original command works just fine, my functions are not called at all. It works with ::tcl::clock::seconds in mysterious way. Other "normal" commands works fine, like "puts" and many others. I'm not quite sure how many other commands behave this way, but seems that majority of commands just working fine with above code (except it is missing calling original proc). PS. No, changing between TCL_EVAL_GLOBAL/TCL_EVAL_DIRECT does not work. Also Tcl_RecordAndEval is critical, using standard eval works just fine (but I expect this is just luck with memory garbage). I'm using VS 2015 with TCL compiled from sources. - foundin changed to: "8.6.8"
- is_private changed to: "0"
- login: "sebastianb"
- priority changed to: "5 Medium"
- private_contact changed to: "2d8ac4b133ec3e161f27387a3b1c25f783d09141"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "sebastianb"
- subsystem changed to: "50. Embedding Support"
- title changed to:
TCL 8.6.8 does not work with Tcl_SetCommandInfo on some commands
- type changed to: "Bug"