Artifacts Associated With Ticket a34733451b
Ticket change [23a7c0edf5] (rid 216329) by fvogel on 2023-07-09 15:39:52:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
Github Actions testing Tk trunk on Linux with the main Tcl (9.0) branch [https://github.com/tcltk/tk/actions/runs/5498558004/jobs/10023375244|results in three errors] that were not present before. <verbatim> ==== imgPhoto-4.79 ImgPhotoCmd, transparency get: no option FAILED ==== Contents of test case: set pixelCoords {{156 239} {76 207} {153 213} {139 43} {75 112}} foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord] } set result ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: can't read "coord": no such variable while executing "photo1 transparency get {*}$coord" ("foreach" body line 2) invoked from within "foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord] }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TCL LOOKUP VARNAME coord ==== imgPhoto-4.79 FAILED ==== imgPhoto-4.81 ImgPhotoCmd, transparency get: -alpha FAILED ==== Contents of test case: set pixelCoords {{156 239} {76 207} {153 213} {139 43} {75 112}} foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord -alpha] } set result ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: can't read "coord": no such variable while executing "photo1 transparency get {*}$coord -alpha" ("foreach" body line 2) invoked from within "foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord -alpha] }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TCL LOOKUP VARNAME coord ==== imgPhoto-4.81 FAILED ==== panedwindow-17.1 MoveSash, move right FAILED ==== Contents of test case: panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 foreach w {.f1 .f2} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew } # Get the requested width of the paned window lappend result [winfo reqwidth .p] .p sash place 0 30 0 # Get the reqwidth again, to make sure it hasn't changed lappend result [winfo reqwidth .p] # Check that the sash moved lappend result [.p sash coord 0] ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: unknown color name "3" (processing "-bg" option) invoked from within "frame $w -height 20 -width 20 -bg $c" ("foreach" body line 2) invoked from within "foreach w {.f1 .f2} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TK LOOKUP COLOR 3 ==== panedwindow-17.1 FAILED </verbatim> plus an additional error message: <verbatim> [...] unixWm.test Test file error: can't read "geom": no such variable util.test [...] </verbatim> Bisection shows that the first commit triggering this regression is [91c2f411e7], that is the merge of [https://core.tcl-lang.org/tips/doc/trunk/tip/636.md|TIP #636] implementation into trunk. In all the four cases, the problem is in a foreach loop apparently not assigning a value to the loop variable. Warning: the problem cannot be reproduced when running only the imgPhoto.test or panedwindow.test file from Tk. Running the entire test suite of Tk allows however to reproduce. - foundin initialized to: "main"
- is_private initialized to: "0"
- login: "fvogel"
- priority initialized to: "5 Medium"
- private_contact initialized to: "a013af67114eccc19ad12b04f14923acea9e96b7"
- resolution initialized to: "None"
- severity initialized to: "Critical"
- status initialized to: "Open"
- submitter initialized to: "fvogel"
- subsystem initialized to: "16. Commands A-H"
- title initialized to: "Regression with TIP #636 in foreach"
- type initialized to: "Bug"
Ticket change [7a0db14b46] (rid 216330) by fvogel on 2023-07-09 15:40:02:
- assignee changed to: "griffin"
- login: "fvogel"
- mimetype: "text/plain"
Ticket change [b02bcab768] (rid 216331) by fvogel on 2023-07-09 16:25:18:
- comment changed to:
Github Actions testing Tk trunk on Linux with the main Tcl (9.0) branch [https://github.com/tcltk/tk/actions/runs/5498558004/jobs/10023375244|results in three errors] that were not present before. <verbatim> ==== imgPhoto-4.79 ImgPhotoCmd, transparency get: no option FAILED ==== Contents of test case: set pixelCoords {{156 239} {76 207} {153 213} {139 43} {75 112}} foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord] } set result ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: can't read "coord": no such variable while executing "photo1 transparency get {*}$coord" ("foreach" body line 2) invoked from within "foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord] }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TCL LOOKUP VARNAME coord ==== imgPhoto-4.79 FAILED ==== imgPhoto-4.81 ImgPhotoCmd, transparency get: -alpha FAILED ==== Contents of test case: set pixelCoords {{156 239} {76 207} {153 213} {139 43} {75 112}} foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord -alpha] } set result ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: can't read "coord": no such variable while executing "photo1 transparency get {*}$coord -alpha" ("foreach" body line 2) invoked from within "foreach coord $pixelCoords { lappend result [photo1 transparency get {*}$coord -alpha] }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TCL LOOKUP VARNAME coord ==== imgPhoto-4.81 FAILED ==== panedwindow-17.1 MoveSash, move right FAILED ==== Contents of test case: panedwindow .p -showhandle false -borderwidth 0 -sashpad 0 -sashwidth 2 foreach w {.f1 .f2} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew } # Get the requested width of the paned window lappend result [winfo reqwidth .p] .p sash place 0 30 0 # Get the reqwidth again, to make sure it hasn't changed lappend result [winfo reqwidth .p] # Check that the sash moved lappend result [.p sash coord 0] ---- Test generated error; Return code was: 1 ---- Return code should have been one of: 0 2 ---- errorInfo: unknown color name "3" (processing "-bg" option) invoked from within "frame $w -height 20 -width 20 -bg $c" ("foreach" body line 2) invoked from within "foreach w {.f1 .f2} c {red blue} { .p add [frame $w -height 20 -width 20 -bg $c] -sticky nsew }" ("uplevel" body line 3) invoked from within "uplevel 1 $script" ---- errorCode: TK LOOKUP COLOR 3 ==== panedwindow-17.1 FAILED </verbatim> plus an additional error message: <verbatim> [...] unixWm.test Test file error: can't read "geom": no such variable util.test [...] </verbatim> Bisection shows that the first commit triggering this regression is [91c2f411e7], that is the merge of [https://core.tcl-lang.org/tips/doc/trunk/tip/636.md|TIP #636] implementation into trunk. In all the four cases, the problem is in a foreach loop apparently not assigning a value to the loop variable. Warning: the problem cannot be reproduced when running only the imgPhoto.test or panedwindow.test file from Tk. Running the entire test suite of Tk allows however to reproduce (on all three platforms). - login: "fvogel"
- mimetype: "text/plain"
- comment changed to:
Ticket change [3cf406d58c] (rid 216332) by griffin on 2023-07-09 19:37:12:
- icomment:
Hard to debug. Requires some prior test(s) to effect state. imgPhoto test seems to run in a subprocess, direct gdb doesn't work. It also seems that child interps are involved. One area of change that is a concern is in the bytecode engine. There are spots where care must be taken when making calls out of the bce when the call has the potential of then calling eval. This creates a recursive call to the bce. The caution is to make sure stack ptr save/restore calls are made, otherwise the stack can be corrupted. Abstract Lists increased the chances of this in places that were not protecting the stack pointer. My suspicion currently is that the Tk tests are somehow uncovering these holes. The debugging continues...
- login: "griffin"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [06430f9a0c] (rid 216368) by chrstphrchvz on 2023-07-11 12:26:36:
- icomment:
This is a duplicate of [6022b9f946]. The bug got merged from main into tip-636-tcl9-644 by [3e44e4bdd3]. The bug was then fixed on main, but the fix somehow did not get merged into tip-636-tcl9-644 during [2f493bd21cb9]. The bug presumably then remained on tip-636-tcl9-644 and was merged back into main by [91c2f411e7].
- login: "chrstphrchvz"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [2f605e9c76] (rid 216372) by jan.nijtmans on 2023-07-11 13:05:31:
- icomment:
@nathan, can you help here? Since you introduced the bug, you should be able to fix it (again). I am aware that the fix is [c405bdd1f0|this commit], but this commit has so many changes that I cannot extract the relevant change from it. It's pure magic to me (which is not meant as a compliment).
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [451d7d2ffe] (rid 216373) by griffin on 2023-07-11 13:47:44:
- icomment:
The problem is with TclDuplicatePureObj(). This function forces a type upon a value which sometimes causes a shimmer. This is bad for abstract lists when called prematurely, i.e. before the value is actually consumed. I had modified the function to prefer src Obj type over the requested type, except when the src was just a string. Any shimmer would already occur later at the point of consumption. The point of failure in this ticket is specifically relying on Dup for type conversion. (A hidden aspect of Dup) The specific value in this case is a variable name previously used, and still exits, as an "index" type. This interfered with the variable lookup because the string was stripped from the obj. It also explains why the test passes when run alone, the variable was not used prior to the test, so did not exist.
- login: "griffin"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [fb5ebc96f3] (rid 216374) by apnadkarni on 2023-07-11 15:23:04:
- icomment:
I don't think preference to the src Obj type over requested type would work in all cases as my reading of some of the calls indicates caller assumes the internal rep is the requested type and directly accesses it accordingly (in particular does not check for errors when further calls fail).
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [a5b2b8bd0f] (rid 216376) by griffin on 2023-07-11 15:44:18:
- icomment:
Converting the type doesn't work in all cases either. That's why it is a bad idea to have 1 function do 2 orthogonal things, make a pure copy, convert the type.
- login: "griffin"
- mimetype: "text/plain"
- icomment:
Ticket change [a6e80750d8] (rid 216399) by griffin on 2023-07-12 03:34:16:
- icomment:
What happened? * Canvas widget defines an option table the includes the string "coords" * Testcase has: "foreach coord $pixelCoords {..." * Internal to the foreach command, a copy of the variable argument is made using TclDuplicatePureObj(). * The "coord" argument ends up as a shared Obj with a type of "index" ObjType. * (this is due to use of an abbreviated "coord" keyword to a canvas command somewhere in an earlier test. Probably hundreds of them.) * The internal rep matches the "coords" value in the canvas option table. * The Dup-Pure removes the string rep, leaving the "index" ObjType internal rep. * The var lookup code requests the string, which is generated from the option table, and returns "coords" * The lookup fails because the variable name is "coord". Take away: * I think TclDuplicatePureObj() is dangerous. Uses should be inspected carefully. * I think the option table implementation is violating consistency promise between internal rep and string rep. This issue has been fixed by replacing TclDuplicatePureObj with Tcl_DuplicateObj(). In this case, the values are var names. It's all about the string here. - login: "griffin"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [9fcc1f8173] (rid 216400) by apnadkarni on 2023-07-12 05:46:40:
- icomment:
Adding my two cents, more to clarify my own thinking: * Tcl values are defined by their string representation as stored in the `Tcl_Obj.bytes` field * `Tcl_DuplicateObj` preserves the value sematics by preserving the `bytes`, while `TclDuplicatePureObj` does not. Consider two objects, both of type `intType` (or whatever the `int` internal rep is) with value 16 but `obj1.bytes` being "16" and `obj2.bytes` being "0x10". These are not equal values but `obj1` and `TclDuplicatePureObj(obj2)` will be equal. * `Tcl_DuplicateObj` was used in at least two ways. One was to make an unshared copy for further modification. The other was to ensure the internal rep remained valid (e.g. iterating a list) even though no modification was planned. `TclDuplicatePureObj` can replace `Tcl_DuplicateObj` in the first instance since anyways the `bytes` will be invalidated. I don't think it can replace in the second instance. All uses need to be examined for which of the two cases applies. * I am a bit uncomfortable with the implementation which copies the `bytes` pointer from the source to the dup object and calls `Tcl_ConvertToType`. I don't know if there are any guarantees that `Tcl_ConvertToType` will not somehow manipulate the allocation if the Tcl_Obj is unshared. May not be a problem now but in the future for all possible types? * Although I initially thought the option table code might also violate consistency, I am not so sure any more based on my `int` example above. It is legitimate to have two string values map to the same internal rep. However, when generated from a string, the string representation *must* be preserved. This does not happen due to `TclDuplicatePureObj`, not because of the option table code.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [3324e48dbe] (rid 216401) by apnadkarni on 2023-07-12 06:06:52:
- icomment:
On further thought, I'll modify my third point as * `Tcl_DuplicateObj` was used in at least two ways. One was to make an unshared copy for further modification. The other was to ensure the internal rep remained valid (e.g. iterating a list) even though no modification was planned. `TclDuplicatePureObj` can replace `Tcl_DuplicateObj` in the first instance since anyways the `bytes` will be invalidated. On the other hand, it can only be applied in the second case in limited cases where the dup'ed object is not preserved. For example, immediately discarded after iteration on a list. In any case, all uses need to be examined for which of the two cases applies.
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [e1663c922f] (rid 216407) by apnadkarni on 2023-07-12 07:35:58:
- icomment:
One more note - the semantics of TclDuplicatePureObj differ between 8.7 and 9.0. Not sure if this is intentional but it adds to the confusion about usage. 8.7 coerces to the passed in typePtr but 9.0 prefers the typePtr of the source Tcl_Obj.
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [f5d3a842e6] (rid 216409) by jan.nijtmans on 2023-07-12 07:55:31:
- icomment:
Whatever recent changes were done to TclDuplicatePureObj() should be backported to 8.7 as well (we don't want the recently discovered bugs discovered in 9.0 to re-appear in 8.7). I never liked the introduction of TclDuplicatePureObj(), but I didn't have much arguments to complain.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [9df653f6cb] (rid 216421) by apnadkarni on 2023-07-12 13:02:36:
- icomment:
My analysis might be misplaced so would be useful to have @pooryorick comment but ... Jan, I noticed you added int, double, index as additional "protected" types to TclDuplicatePureObj. Since lists (abstract and traditional) can also have the same issue - multiple string representations for the same internal rep - should those also be protected. In which case one wonders what's left and whether the whole exercise is worthwhile. Originally, the list code used TclListObjCopy as a specialized internal function. It was important from a performance perspective within its limited context. TclDuplicatePureObj generalizes it to do more but given it does not preserve value semantics its applicability is limited to those same use cases. That hints to me that the protections be removed, and the semantics of the function changed to reflect values are not preserved, only intreps are, and all call sites changed to revert to Tcl_DuplicateObj when they fall outside those limited use cases. Alternately, each type could revert back to its own specialized "internal copy" as the list implementation used to. This also avoid all the checks present in the "generalized" TclDuplicatePureObj.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [03bfea39d6] (rid 216422) by pooryorick on 2023-07-12 13:37:54:
- icomment:
The TIP #636 code should be reverted from trunk until it can be successfully merged without causing this regression. I've warned that TIP 636 is not ready for prime time, and this issue report is evidence of that. TclDuplicatePureObj() should not be compromised in order to accommodate TIP 636. Rather, the TIP 636 should be modified to not interact with TclDuplicatePureObj() at all. If the TIP 636 work does interact with TclDuplicatePureObj() it is a bug in the implementation of TIP 636. TclDuplicatePuerObj() should not be modified to be sensitive to internal representations that seem to implement a Tcl_Obj interface. Such a modification would be a hack in lieu of a correct implementation of TIP 636.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [1b51017c06] (rid 216423) by jan.nijtmans on 2023-07-12 13:49:19:
- icomment:
> In which case one wonders what's left and whether the whole exercise is worthwhile I'm having the same doubt! The only type I see which doesn't have this problem is the ArithSeries objType. I would like to throw away the TclDuplicatePureObj() function, but first we need to discuss what to do instead ....
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [0d2cbac76b] (rid 216424) by griffin on 2023-07-12 13:53:15:
- icomment:
pooryorick: #636 is not the problem. TclDuplicatePureObj has been used incorrectly or indiscriminately, that is the problem.
- login: "griffin"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [42b569e576] (rid 216425) by jan.nijtmans on 2023-07-12 13:54:25:
- icomment:
@Nathan. Your TclDuplicatePureObj() changes, which broke he build in your first commit are the cause of the trouble with TIP #636. So I suggest to revert the changes you introduced, until they work well with TIP #636 :-)
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [a58fbbcc64] (rid 216426) by jan.nijtmans on 2023-07-12 13:57:29:
- icomment:
Ashok wrote: > My analysis might be misplaced so would be useful to have @pooryorick comment but ... I think your analysis is well-done. It's very clear to me.
- login: "jan.nijtmans"
- mimetype: "text/plain"
- icomment:
Ticket change [b8f5dcadc8] (rid 216428) by pooryorick on 2023-07-12 14:04:31:
- icomment:
The TIP #636 code should be reverted from trunk until it can be successfully merged without causing this regression. I've warned that TIP 636 is not ready for prime time, and this issue report is evidence of that. TclDuplicatePureObj() should not be compromised in order to accommodate TIP 636. Rather, the TIP 636 should be modified to not interact with TclDuplicatePureObj() at all. If the TIP 636 work does interact with TclDuplicatePureObj() it is a bug in the implementation of TIP 636. TclDuplicatePureObj() should not be modified to be sensitive to internal representations that seem to implement a Tcl_Obj interface. Such a modification would be a hack in lieu of a correct implementation of TIP 636.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [305896c27d] (rid 216430) by pooryorick on 2023-07-12 14:06:32:
- icomment:
Oops, please disregard the previous repeated message. Here is the new message: The last trouble reported with TclDuplicatePureObj() was fixed almost two months ago, in [c405bdd1f0]. Since then there have been no test failures until the merge of TIP 636. That clearly indicates that the trouble is with the TIP 636 merge, and that's what should be reverted here.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [3c8216c928] (rid 216435) by jan.nijtmans on 2023-07-12 14:51:08:
- icomment:
> The TIP #636 code should be reverted from trunk until it can be successfully merged without causing this regression Build is passing now, so no worries. I'm not closing this ticket yet, until we decided what to with TclDuplicatePureObj()
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- icomment:
Ticket change [6637783ec9] (rid 216453) by griffin on 2023-07-12 20:40:19:
- closedate changed to: "2460138.36134127"
- closer changed to: "griffin"
- login: "griffin"
- mimetype: "text/plain"
- status changed to: "Closed"
Ticket change [a8c0b2f193] (rid 216460) by fvogel on 2023-07-13 06:18:50:
- closedate changed to: "2460138.76308289"
- closer changed to: "fvogel"
- icomment:
> Build is passing now The Github job [https://github.com/tcltk/tk/actions/runs/5528545145/attempts/1|failed] yesterday morning. I see you simply re-ran the job and this time [https://github.com/tcltk/tk/actions/runs/5528545145|it passed]. How come...?? There was no fixes between the first and the second attempt, isn't it? Besides: my thanks to everyone involved in this ticket!
- login: "fvogel"
- mimetype: "text/x-fossil-wiki"
Ticket change [051cd53330] (rid 216461) by jan.nijtmans on 2023-07-13 06:52:07:
- closedate changed to: "2460138.78619687"
- closer changed to: "jan.nijtmans"
- icomment:
> How come...?? In GitHub, the Tk builds are done _before_ the Tcl builds. That means that when Tk builds, Tcl doesn't have the latest commits from fossil yet. So, I re-ran the Tk build after Tcl synced. :-)
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [a2adb801ba] (rid 216462) by fvogel on 2023-07-13 07:48:36:
- closedate changed to: "2460138.82541757"
- closer changed to: "fvogel"
- icomment:
This explanation indeed makes a lot of sense! Do we control when the jobs are launched in each particular project?
- login: "fvogel"
- mimetype: "text/plain"
Ticket change [ec0a07cca3] (rid 230459) by pooryorick on 2024-08-20 14:48:55:
- closedate changed to: "2460543.11730567"
- closer changed to: "pooryorick"
- icomment:
Doing some post-mortem analysis on this, Brian said below, "The Dup-Pure removes the string rep, leaving the "index" ObjType internal rep.". <code>TclDuplicatePureObj()</code> would not remove the string representation of an individual item in the list when converting the type to tclListType, It is only the full list representation which is discarded, and <code>SetListFromAny()</code> sees to it that each individual list item has a string representation when converting a value of another type to a string. Therefore it is safe to use <code>TclDuplicatePureObj()</code> to duplicate into a list type. There's something to this story that was not discovered.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"