Overview
| Artifact ID: | 2fb355afb4ff1f391b7243920a5439cf22e18d26 |
|---|---|
| Ticket: | 218457ffffffffffffffffffffffffffffffffff
Tcl_ForeachObjCmd bug in Tcl8.0p2 |
| User & Date: | nobody on 2000-10-26 01:00:37 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 605 Bug Version: 8.0p2 SubmitDate: '1998-05-21' LastModified: '1999-08-06' Severity: SER Status: Released Submitter: hershey ChangedBy: hobbs OS: All OSVersion: NA Machine: NA FixedDate: '1999-08-06' FixedInVersion: 8.1.1 ClosedDate: '2000-10-25' There is a object reference count problem in Tcl_ForeachObjCmd in Tcl8.0p2. Tcl_ListObjGetElements does not increment the reference counts on the objects, so storing the objects in arrays and using them each time through the loop doesn't work. I tried incrementing the reference counts but this didn't work either. What did work was extracting the elements each time through the loop. Here is a patch. I know this is of dubious worth because I didn't track down the exact cause of the bug, but the reference count stuff is confusing and I don't have time to sort it out. John *** tclCmdAH.c 1998/04/10 18:56:28 1.1 --- tclCmdAH.c 1998/04/13 22:39:26 *************** *** 1530,1554 **** bodyPtr = argObjv[objc-1]; for (j = 0; j < maxj; j++) { for (i = 0; i < numLists; i++) { ! /* ! * If a variable or value list object has been converted to ! * another kind of Tcl object, convert it back to a list object ! * and refetch the pointer to its element array. ! */ ! ! if (argObjv[1+i*2]->typePtr != &tclListType) { ! result = Tcl_ListObjGetElements(interp, argObjv[1+i*2], ! &varcList[i], &varvList[i]); ! if (result != TCL_OK) { ! panic("Tcl_ForeachObjCmd: could not reconvert variable list %d to a list object\n", i); ! } } ! if (argObjv[2+i*2]->typePtr != &tclListType) { ! result = Tcl_ListObjGetElements(interp, argObjv[2+i*2], &argcList[i], &argvList[i]); ! if (result != TCL_OK) { ! panic("Tcl_ForeachObjCmd: could not reconvert value list %d to a list object\n", i); ! } } for (v = 0; v < varcList[i]; v++) { --- 1530,1544 ---- bodyPtr = argObjv[objc-1]; for (j = 0; j < maxj; j++) { for (i = 0; i < numLists; i++) { ! result = Tcl_ListObjGetElements(interp, argObjv[1+i*2], ! &varcList[i], &varvList[i]); ! if (result != TCL_OK) { ! panic("Tcl_ForeachObjCmd: could not reconvert variable list %d to a list object\n", i); } ! result = Tcl_ListObjGetElements(interp, argObjv[2+i*2], &argcList[i], &argvList[i]); ! if (result != TCL_OK) { ! panic("Tcl_ForeachObjCmd: could not reconvert value list %d to a list object\n", i); } for (v = 0; v < varcList[i]; v++) { This has been fixed as of (or before) 8.1. -- 08/06/1999 hobbs - foundin changed to: "obsolete: 8.0p2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "10. Objects"
- title changed to: "Tcl_ForeachObjCmd bug in Tcl8.0p2"
- type changed to: "Bug"