Artifacts Associated With Ticket 1366195fffffffffffffffffffffffffffffffff
Ticket change [83dec42e62] (rid 117446) by afredd on 2005-11-25 10:40:37:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
A nice easy one... On windows, if you redefine TCL_DSTRING_STATIC_SIZE to be small (4!) then it crashes in TclpGetEncodingNameFromEnvironment because it assumes the DString buffer is large enough. I've not seen anything stating a minimum size for this so assume this is 'allowed'. Something like: TclpGetEncodingNameFromEnvironment(bufPtr) Tcl_DString *bufPtr; { Tcl_DStringInit(bufPtr); +#define MIN_DSTRING_LEN (3 + TCL_INTEGER_SPACE) +#if TCL_DSTRING_STATIC_SIZE < MIN_DSTRING_LEN + Tcl_DStringSetLength(bufPtr, MIN_DSTRING_LEN); +#endif wsprintfA(Tcl_DStringValue(bufPtr), "cp%d", GetACP ()); return Tcl_DStringValue(bufPtr); } seems like the simplest fix, as not many people are going to hit this problem. After hittng this problem i had a quick look for any other potentially similar problems and saw this in tclWinDde.c: #line 367 Tcl_DStringSetLength(&dString, offset + TCL_INTEGER_SPACE); I think this should be: Tcl_DStringSetLength(&dString, Tcl_DStringLength(&dString) + offset + TCL_INTEGER_SPACE); ...but again it's only a problem if TCL_DSTRING_STATIC_SIZE is small. - foundin initialized to: "obsolete: 8.5a3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "afredd"
- subsystem initialized to: "None"
- title initialized to: "win: if TCL_DSTRING_STATIC_SIZE is small => crash"
- type initialized to: "RFE"
Ticket change [35820cd20c] (rid 106950) by dkf on 2005-11-25 23:06:42:
- assignee changed to: "dgp"
- icomment:
Logged In: YES user_id=79902 I'm not quite sure what to do about this given that the submitter is changing a fundamental constant...
- login: "dkf"
- mimetype: "text/plain"
- subsystem changed to: "10. Objects"
- username: "dkf"
Ticket change [9743e8dc0b] (rid 106475) by dgp on 2005-11-27 09:13:31:
- assignee changed to: "dkf"
- foundin changed to: "None"
- icomment:
data_type - 360894 Logged In: YES user_id=80530 Submitter is correct that since we have a symbolic value, it would be better to use it than to assume we know what its value is. Doing so would allow source hackers to try different values with less worry about breaking stuff. That said, supporting source hackers is fairly low on our To Do list; they can take care of themselves for the most part. I could have left this as a low priority bug report, but I'm switching it to a feature request. There's nothing really buggy here, since tweaking these values isn't something we really support. The change is something that ought to be done, but unless a contributed patch comes in, the usual maintainers probably will work on more pressing matters.
- login: "dgp"
- mimetype: "text/plain"
- priority changed to: "2"
- subsystem changed to: "10. Objects"
- title changed to:
Use TCL_DSTRING_STATIC_SIZE rather than assume size
- username: "dgp"
Ticket change [fb44cabf26] (rid 92027) by afredd on 2006-03-31 20:28:12:
- icomment:
Logged In: YES user_id=1386588 Here's the requested patch.
- login: "afredd"
- mimetype: "text/plain"
- username: "afredd"
- icomment:
Add attachment "tclWinInit.c-1.69-patch" [63b7d8c3f3] (rid 92629) by afredd on 2006-03-31 20:28:12.
Ticket change [e0c319ce32] (rid 87335) by afredd on 2006-03-31 20:28:19:
- icomment:
File Added - 172901: tclWinInit.c-1.69-patch
- login: "afredd"
- mimetype: "text/plain"
- username: "afredd"
- icomment:
Ticket change [7e24cdd620] (rid 97355) by dgp on 2006-03-31 23:35:31:
- icomment:
Logged In: YES user_id=80530 thanks for the patch. Looking it over, I see it would catch any problems with a source hacker trying to make TCL_DSTRING_STATIC_SIZE smaller than Tcl assumes it is. The patch I'd rather have is changes to Tcl so it stops making assumptions about how large the value is.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [576b967621] (rid 94486) by afredd on 2006-04-04 00:20:15:
- icomment:
Logged In: YES user_id=1386588 dgp: >The patch I'd rather have is changes to Tcl so it >stops making assumptions about how large the value is. The patch fixes the only case i can find of the core assuming a certain size for TCL_DSTRING_STATIC_SIZE. Or do you mean that, for example, a core compiled with TDSS==300, should support an extension compiled with TDSS==100? ie. DStringInit would need to pass in its static buffer buffer size which would probably be needed to be stored in the DString struct. Sounds like it would break a lot of binary interfaces... and not for a lot of gain. (So probably this isn't what you meant ;-)
- login: "afredd"
- mimetype: "text/plain"
- username: "afredd"
- icomment:
Ticket change [109a8b0ccf] (rid 94997) by dgp on 2006-04-04 00:55:46:
- icomment:
Logged In: YES user_id=80530 No, all users of TCL_DSTRING_STATIC_SIZE ought to use the value given to them in tcl.h. Because we specify a value publicly, we would have to think carefully before ever changing it, in case some extensions use of the value in an old header conflcts with the new value we would want in a new header. So, making any change to this value makes sense only in very narrow circumstances, like someone customizing Tcl for their own specialized needs (low-memory environment?) and maintaining enough control to not run into the "old extension" problem. The change that would help them a bit would be to patch Tcl's source code so that it did not assume a value of TCL_DSTRING_STATIC_SIZE, but just used whatever value the header provided. The patch submitted did the opposite, setting a limit on what value of TCL_DSTRING_STATIC_SIZE can get set.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [d70c6ce1aa] (rid 123910) by afredd on 2006-04-04 15:50:41:
- icomment:
Logged In: YES user_id=1386588 >The change that would help them a bit would be >to patch Tcl's source code so that it did not >assume a value of TCL_DSTRING_STATIC_SIZE, but >just used whatever value the header provided. > ie. replace TDSS with literal "200"'s in the core? >The patch submitted did the opposite, setting a >limit on what value of TCL_DSTRING_STATIC_SIZE >can get set. You mean an extension comiled with TDSS==4 using Tcl_GetEncodingNameFromEnvironment linked to a core with a regular TDSS==200 wouldn't have it DString lengthened, and would still crash. Good point - i hadn't thought of that. The fix would be to remove the #if-ery, and just always: Tcl_DStringSetLength(bufPtr,(2*(3+TCL_INTEGER_SPACE))); My patch was only intended to allow TDSS to be set low and not cause a stack corruption. Allowing for varying values of TDSS between extensions and the core is a whole different ball game. My opinion is that it is merely a documentation issue - caveat programmor.
- login: "afredd"
- mimetype: "text/plain"
- username: "afredd"
- icomment:
Ticket change [80f74f5331] (rid 116956) by dgp on 2006-04-05 00:46:46:
- icomment:
Logged In: YES user_id=80530 looking again at the original report, the code in tclWinDde.c looks fine to me, and looks like the right way to fix the problem with TclpGetEncodingNameFromEnvironment(). Patch coming soon.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b5f537ca14] (rid 125340) by dgp on 2006-04-05 02:05:44:
- assignee changed to: "dgp"
- icomment:
Logged In: YES user_id=80530 waiting for cvs...
- login: "dgp"
- mimetype: "text/plain"
- priority changed to: "9 Immediate"
- username: "dgp"
Add attachment "1366195.patch" [e4af162dad] (rid 87998) by dgp on 2006-04-05 22:57:25.
Ticket change [82e1cb507f] (rid 117303) by dgp on 2006-04-05 22:57:25:
- icomment:
Logged In: YES user_id=80530 here's a patch that corrects these problems and updates some overlooked version number bumps as well.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [06da09089d] (rid 89283) by dgp on 2006-04-05 22:57:26:
- icomment:
File Added - 173519: 1366195.patch
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [6422335cbe] (rid 92709) by dgp on 2006-04-05 23:53:30:
- closedate changed to: "2006-04-05T16:53:30"
- closer changed to: "dgp"
- icomment:
Logged In: YES user_id=80530 committed
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Accepted"
- status changed to: "Closed"
- username: "dgp"