From: SourceForge.net <no...@so...> - 2007-10-09 02:12:43
|
Patches item #1809819, was opened at 2007-10-08 12:03 Message generated for change (Comment added) made by cliff_c You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=1809819&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Cliff C (cliff_c) Assigned to: Nobody/Anonymous (nobody) Summary: prevent SWIG_Tcl_ConvertPtr from calling the unknown proc Initial Comment: SWIG_Tcl_ConvertPtrFromString is called whenever a std::vector<> is used in an exported function. This is to check whether the object passed is actually a SWIG-owned pointer to a vector. It may be a native list, but the check for a pointer always happens first. The pointer check takes the argument and calls it like so: <argument> cget -this. If this fails, it knows it's not a pointer. The bad thing is that, if it's not a pointer, as part of the call to <argument> cget -this, the unknown proc will be called. This proc may be overridden by any Tcl user, and if it is, weird things may happen here. The fix to this (admittedly obscure) issue is to first check whether <argument> is a command, and _then_ call cget -this on it. The change is to tclrun.swg. The new code was added between "/* Hmmm..." and "if (Tcl_VarEval(interp, c,"cget -this"...": To test, you'd need a .i that uses vector (see the standard examples for that), and to redefine unknown to puts something when it is called (shown here): rename unknown unknown_orig proc unknown {args} {puts "unknown called because of: $args"; uplevel 1 unknown_orig $args} ---------------------------------------------------------------------- >Comment By: Cliff C (cliff_c) Date: 2007-10-08 16:12 Message: Logged In: YES user_id=1908690 Originator: YES File Added: Examples_tcl_std_vector.tgz ---------------------------------------------------------------------- Comment By: Cliff C (cliff_c) Date: 2007-10-08 16:10 Message: Logged In: YES user_id=1908690 Originator: YES File Added: example.h ---------------------------------------------------------------------- Comment By: Cliff C (cliff_c) Date: 2007-10-08 16:09 Message: Logged In: YES user_id=1908690 Originator: YES I will attach the output of diff and a new std_vector example for tcl (stolen from python except for the runme.tcl) that will illustrate the bug. File Added: tclrun.patch ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2007-10-08 13:35 Message: Logged In: YES user_id=14972 Originator: NO We don't have an active Tcl maintainer at present I'm afraid. I can take a look at applying this fix, but my Tcl understanding is limited, so it would be very useful if you could provide an actual test case suitable for including under Examples (I would really struggle to construct one just from your description of how to do so). Also, can you provide a patch rather than the entire patched file (you can use "svn diff" to generate it). It's hard to review changes without seeing a patch. ---------------------------------------------------------------------- Comment By: Cliff C (cliff_c) Date: 2007-10-08 12:59 Message: Logged In: YES user_id=1908690 Originator: YES Updated patch to include the case where the <argument> is an empty string and where it is multiple words, neither of which are commands. File Added: tclrun.swg ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=1809819&group_id=1645 |