| Ticket UUID: | 2492179 | |||
| Title: | config.test failures - DoObjConfig | |||
| Type: | Bug | Version: | obsolete: 8.6b1 | |
| Submitter: | dgp | Created on: | 2009-01-07 14:46:03 | |
| Subsystem: | 23. Option Parsing | Assigned To: | dgp | |
| Priority: | 9 Immediate | Severity: | ||
| Status: | Closed | Last Modified: | 2009-12-16 01:08:58 | |
| Resolution: | Fixed | Closed By: | dgp | |
| Closed on: | 2009-12-15 18:08:58 | |||
| Description: |
Don't recall seeing these before:
config.test
==== config-4.111 DoObjConfig - custom FAILED
==== Contents of test case:
testobjconfig alltypes .foo -custom test
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0
---- errorInfo: unknown color name "test"
(processing "-custom" option)
invoked from within
"testobjconfig alltypes .foo -custom test"
("uplevel" body line 2)
invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== config-4.111 FAILED
==== config-4.112 DoObjConfig - custom FAILED
==== Contents of test case:
testobjconfig alltypes .foo -custom test
.foo cget -custom
---- Test generated error; Return code was: 1
---- Return code should have been one of: 0
---- errorInfo: unknown color name "test"
(processing "-custom" option)
invoked from within
"testobjconfig alltypes .foo -custom test"
("uplevel" body line 2)
invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== config-4.112 FAILED
==== config-7.13 Tk_SetOptions - error in DoObjConfig with custom option FAILED
==== Contents of test case:
.a configure -custom bad
---- Result was:
unknown color name "bad"
---- Result should have been (exact matching):
expected good value, got "BAD"
==== config-7.13 FAILED
==== config-7.14 Tk_SetOptions - error in DoObjConfig with custom option FAILED
==== Contents of test case:
catch {.a configure -custom bad}
return $errorInfo
---- Result was:
unknown color name "bad"
(processing "-custom" option)
invoked from within
".a configure -custom bad"
---- Result should have been (exact matching):
expected good value, got "BAD"
(processing "-custom" option)
invoked from within
".a configure -custom bad"
==== config-7.14 FAILED
| |||
| User Comments: |
dgp added on 2009-12-16 01:08:58:
allow_comments - 1 That's much less of a hatchet job than my answer, thanks. Possibly a bit of a kludge, but effective. New patch file takes the nijtmans solution and adds removal of registration of the "option" Tcl_ObjType as well as making the conversions to static file scope that change enables. Committing as a fix to HEAD. Leaving 8.5 branch alone, since it's only NRE which really exposes the problems, IME. dgp added on 2009-12-16 01:06:53: File Added - 355328: 2492179-2.patch nijtmans added on 2009-12-11 22:32:09: B.T.W. I agree with "nobody" that registring the "option"
object type is not useful at all. No extension calling
Tcl_GetObjType("option") can do anything useful
with the result.
nijtmans added on 2009-12-11 22:19:05: File Added - 354819: tkConfig.c.patch nijtmans added on 2009-12-11 22:18:17: Or, simply equip OptionTable with a second reference counter, which controls nothing more than the freeing of the memory. Upon creation, this counter will be started with value 1. Every time the OptionTable is referenced from an "option" object, the counter is incremented, and whenever the "option" object is destroyed the counter is decremented. Tk_DeleteOptionTable only does the final ckfree if the counter reached zero (after decrementing) Here is the patch "tkConfig.c.patch" which does exactly that. The test passes with that. ;-) dgp added on 2009-12-10 02:06:28: Attached is the "disable the 'option' type" patch. dgp added on 2009-12-10 02:05:54: File Added - 354555: 2492179.patch [email protected] added on 2009-01-22 01:21:09: It's not necessary to remove the "option" ObjType -- it's only broken in the presence of Tk_DeleteOptionTable(), which nobody seems to call. Nothing in the core does (anymore), and none of the third-party widget libraries I've looked at do either. (Tile did, in one place, but doesn't any more). The bug really only affects the test suite.
(OTOH, it's not necessary to *register* the ObjType, either: nothing that calls Tcl_GetObjType("option") can do anything useful with the result. Same goes for all of the other Tk ObjTypes. That's a different issue though.)
The "option" objType does perform useful caching. Might be less useful now, since increased literal sharing will lead to increased shimmering.
I don't object to removing it if that's the quickest way to close the issue. (Reworking config.test and generic/tkTest.c to not call Tk_DeleteOptionTable is the other way; but that's more work and not Strictly Correct.)
dgp added on 2009-01-22 00:20:31:
The potential for trouble with
that plan is that Tk registers
the "option" Tcl_ObjType, so any
extension that calls
Tcl_GetObjType("option")
will be broken. Anything known
to do that?
dgp added on 2009-01-21 23:34:07: Elimination of the broken "option" Tcl_ObjType appears to be a simple an effective fix. dgp added on 2009-01-21 23:20:52: FWIW, the misdesigned "option" Tcl_ObjType was committed in Revision 1.3, "merge 8.1 branch". dgp added on 2009-01-20 03:21:42: The obvious difficulty with the proposed answer is that Tk_DeleteOptionTable() appears public. Even if we avoid calling it, we should (perhaps at lower priority) erect some defenses against extensions that call it. A complete rewrite that's not broken is another longer term answer. I don't have a good sense how tall an order that is. jenglish added on 2009-01-19 02:04:44: > So the problem is [...] That's the first part: Tcl_Objs with "option" intreps holding dangling pointers. The second part is when Tk_CreateOptionTable() allocates a new option table that happens to occupy the same storage as a previously freed option table; part three is when a Tcl_Obj * with a dangling pointer into the old table is used with the new one. This explains all of the config.test failures, #2496162, and why they didn't manifest before [source] was NRE-enabled. If the conclusion to be drawn is "widget code should not call Tk_DeleteOptionTable" (which I think it is), then I'm not sure what to do about config.test, since it spends a great deal of effort exercising that routine. dgp added on 2009-01-17 05:23:08: So the problem is that Tk_DeleteOptionTable can clear away an array of Option's while who knows how many Tcl_Obj intreps of the "option" Tcl_ObjType are still holding pointers into that array? jenglish added on 2009-01-15 03:32:49: Duh! Diagnosis for #2496162 applies here too -- Tk_DeleteOptionTable() is not safe if there are any tkOptionObjType Tcl_Obj*s lying around. Evidence that this is the source of the problem: stubbed out the caching logic in GetOptionFromObj(), ran config.test in a loop, it's gone >200 times in a row with no errors. jenglish added on 2009-01-15 01:01:37: Purported fix does not, in fact, work. Sporadic failures in config.test have come back. I still suspect a bug in tkTest.c (likely) or tkConfig.c (less likely) that's being tickled by increased literal sharing, but what that bug is I cannot tell. jenglish added on 2009-01-13 00:54:18: > Anything still holding back a fix here? No, just ran out of free time yesterday. Will try to get to it today. dgp added on 2009-01-13 00:15:40: 2496162 has been closed. Anything still holding back a fix here? jenglish added on 2009-01-11 08:21:27: I have a fix, but will hold off committing until #2496162 is resolved -- I suspect the two bugs are related (something screwy going on in Tk option processing, possibly being tickled by recent NRE-enabling of [source]), and this one is a lot easier to replicate than that one. jenglish added on 2009-01-11 07:47:25: Probable cause of the problem: generic/tkTest.c r1.41, routine CustomOptionSet, lines 2138-2139 directly modifies the string rep of a Tcl_Obj * without first ensuring that it's unshared: | string = Tcl_GetStringFromObj((*value), &length); | Tcl_UtfToUpper(string); Additional debug printfs() indicate that when running config.test, this code path is indeed taken when (*value) has a refcount > 1. jenglish added on 2009-01-11 06:55:28: More info: tried several versions of Tk (using `git bisect`) against Tcl CVS HEAD (as of 9 Jan 2009); getting sporadic, nondeterministic failures for tests in the range config-4.108 through config-4.115, and config-7.13/7.14 for all versions of Tk going back to tag core-8.6a1. Tried various combinations of valgrind, -DPURIFY, --enable-symbols=mem; none of them bark, but I occasionally get a coredump. Again, nondeterministally and sporadically -- can't reliably replicate -- but the coredump usually (always?) occurs somewhere in tkConfig.c. Consistent pattern in the test failures: setting the "-custom" option of a Test widget created by [testobjconfig] signals an error "bad <color name|window path name| other thing> XXX", where "XXX" is usually (but not always? Don't remember now and can't replicate, sigh...) the value specified for "-custom". dgp added on 2009-01-10 02:57:51: I get similar failures using the actual release sources of Tk 8.6b1 when built against the Tcl HEAD. I do not get the failures building against the Tcl 8.6b1 sources as released. The bug may well still be in Tk. But the triggering cause seems to be some post-8.6b1 commit to Tcl. Leading suspect is NRE-enabling of [source]. | |||
Attachments:
- 2492179-2.patch [download] added by dgp on 2009-12-16 01:06:53. [details]
- tkConfig.c.patch [download] added by nijtmans on 2009-12-11 22:19:05. [details]
- 2492179.patch [download] added by dgp on 2009-12-10 02:05:54. [details]
