Ticket UUID: | 1008314 | |||
Title: | Tcl_*SetVar* mishandle TCL_LIST_ELEMENT | |||
Type: | Bug | Version: | obsolete: 8.4.7 | |
Submitter: | dgp | Created on: | 2004-08-12 22:26:31 | |
Subsystem: | 07. Variables | Assigned To: | msofer | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2004-08-16 21:18:53 | |
Resolution: | Fixed | Closed By: | msofer | |
Closed on: | 2004-08-16 14:18:53 | |||
Description: |
The TclPtrSetVar() routine processes the TCL_LIST_ELEMENT flag only when the TCL_APPEND_VALUE flag is also set. This is an error that was introduced in revision 1.32 of tclVar.c. For example, Tcl_SetVar(i, "x", "a b", TCL_LIST_ELEMENT); will set the value of x to be "a b" and not "{a b}" as it should according to the docs. The public routine Tcl_SetErrorCode() can also be used to demo this bug. In particular Tcl_SetErrorCode(i, "{", NULL); will store a value in ::errorCode that is not a valid Tcl list. | |||
User Comments: |
msofer added on 2004-08-16 21:18:53:
Logged In: YES user_id=148712 Applied to HEAD and core-8-4-branch msofer added on 2004-08-16 20:58:01: Logged In: YES user_id=148712 From the chat: dkf "Why are you worrying about testseterrorcode? It's a testing API; it's allowed to be unsafe" dgp "TclInvokeStringCommand passes an argv of minimum length 20, so testseterrorcode should be safe. ...and argv[argc] is guaranteed to be NULL." msofer added on 2004-08-14 22:20:56: Logged In: YES user_id=148712 I do not understand TclseterrorcodeCmd (in the patch) very well: it passes argv[5] to Tcl_SetErrorCode() even when (argc==3). Isn't this dangerous, as in setting up a possible segfault? dgp added on 2004-08-13 21:21:24: File Deleted - 97490: File Added - 97590: 1008314.patch dgp added on 2004-08-13 21:21:23: Logged In: YES user_id=80530 New patch includes the fixes. Please review, test, apply, and backport. dgp added on 2004-08-13 06:57:28: Logged In: YES user_id=80530 On the latter point, the T_LOAE routine has been in use for this operation since Tcl 8.0, it appears, so this change can safely be considered to be one of the Tcl 7 -> Tcl 8 incompatibilities. Only change that might be needed is improved documentation on the point. dgp added on 2004-08-13 06:12:18: Logged In: YES user_id=80530 Another possible error here is that when both TCL_LIST_ELEMENT and TCL_APPEND_VALUE are set, then the Tcl_ListObjAppendElement() routine is used to do the work. Use of T_LOAE adds the constraint that the value of the variable to which we are appending must already be a valid list.. I don't think that's a documented requirement of the Tcl_*SetVar* routines. On that point, a documentation fix is probably more attractive than a code change. dgp added on 2004-08-13 05:59:18: File Added - 97490: 1008314.patch Logged In: YES user_id=80530 The attached patch (against the HEAD) adds tests to the test suite that demo this bug. |
Attachments:
- 1008314.patch [download] added by dgp on 2004-08-13 21:21:23. [details]