Artifacts Associated With Ticket f3cb2a32d6
Ticket change [a39ab5420b] (rid 209766) by dgp on 2023-03-06 17:24:24:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- comment initialized to:
A valgrind run exposes trouble in test format-2.18 ==19961== Conditional jump or move depends on uninitialised value(s) ==19961== at 0x5A7CF7: Tcl_UniCharToUtf (tclUtf.c:231) ==19961== by 0x59952D: ExtendStringRepWithUnicode (tclStringObj.c:4853) ==19961== by 0x5993C0: UpdateStringOfString (tclStringObj.c:4794) ==19961== by 0x57025B: Tcl_GetStringFromObj (tclObj.c:1705) ==19961== by 0x595DBD: Tcl_AppendFormatToObj (tclStringObj.c:2955) ==19961== by 0x59603F: Tcl_Format (tclStringObj.c:3029) ==19961== by 0x488590: TclCompileFormatCmd (tclCompCmds.c:3190) ==19961== by 0x50A4E3: TclAttemptCompileProc (tclEnsemble.c:3298) ==19961== by 0x4E6873: CompileCmdCompileProc (tclCompile.c:1993) ==19961== by 0x4E6EE2: CompileCommandTokens (tclCompile.c:2109) ==19961== by 0x4E745C: TclCompileScript (tclCompile.c:2269) ==19961== by 0x4E41FE: TclSetByteCodeFromAny (tclCompile.c:838) ==19961== by 0x5111D6: TclCompileObj (tclExecute.c:1776) ==19961== by 0x437DC0: TclNREvalObjEx (tclBasic.c:6732) ==19961== by 0x5868E5: TclNRUplevelObjCmd (tclProc.c:985) ==19961== by 0x434E1F: Dispatch (tclBasic.c:4997) ==19961== by 0x434EA7: TclNRRunCallbacks (tclBasic.c:5037) ==19961== by 0x434773: Tcl_EvalObjv (tclBasic.c:4756) ==19961== by 0x436DD5: TclEvalEx (tclBasic.c:5913) ==19961== by 0x559F7D: Tcl_FSEvalFileEx (tclIOUtil.c:1782) ==19961== by 0x5669A6: Tcl_MainEx (tclMain.c:405) ==19961== by 0x410188: main (tclAppInit.c:94)
- foundin initialized to: "core-8-branch"
- is_private initialized to: "0"
- login: "dgp"
- priority initialized to: "5 Medium"
- private_contact initialized to: "8e2300e85be5dd1445b9666eb9429055951e33be"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "10. Objects"
- title initialized to: "uninitialized value in format-2.18"
- type initialized to: "Bug"
Ticket change [653375e3ea] (rid 209775) by jan.nijtmans on 2023-03-06 19:39:01:
- assignee changed to: "jan.nijtmans"
- login: "jan.nijtmans"
- mimetype: "text/plain"
Ticket change [125371f964] (rid 209780) by jan.nijtmans on 2023-03-06 20:55:51:
- icomment:
Proposed fix [05e83f801a8a2f3c|here] In Tcl 8.7, if Tcl_UniCharToUtf() is fed a lower surrogate, it checks if the previous Tcl_UniCharToUtf() call produced an upper surrogate. This previous result is stored in dst[0] and dst[1], but in this situation those two bytes are uninitialized. Initializing dst[0] just before the Tcl_UniCharToUtf() should help.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- icomment:
Ticket change [d9022ca2aa] (rid 209805) by jan.nijtmans on 2023-03-07 07:07:52:
- closedate changed to: "2460010.79713341"
- closer changed to: "jan.nijtmans"
- icomment:
Fixed [b01a3c55eda6af6d|] here (for 8.7 only, not needed in 9.0)
- login: "jan.nijtmans"
- mimetype: "text/plain"
- status changed to: "Closed"
Ticket change [b1e5a847c0] (rid 209914) by dgp on 2023-03-08 17:37:37:
- closedate changed to: "2460012.23445676"
- closer changed to: "dgp"
- icomment:
This change shifts the failure to a similar problem in the following test format-2.19: ---- format-2.19 start ==6436== Conditional jump or move depends on uninitialised value(s) ==6436== at 0x5A7E59: Tcl_UniCharToUtf (tclUtf.c:231) ==6436== by 0x59968F: ExtendStringRepWithUnicode (tclStringObj.c:4854) ==6436== by 0x59951B: UpdateStringOfString (tclStringObj.c:4794) ==6436== by 0x5703B6: Tcl_GetStringFromObj (tclObj.c:1705) ==6436== by 0x593752: Tcl_AppendObjToObj (tclStringObj.c:1862) ==6436== by 0x4E59AC: TclWordKnownAtCompileTime (tclCompile.c:1783) ==6436== by 0x488512: TclCompileFormatCmd (tclCompCmds.c:3170) ==6436== by 0x50A63E: TclAttemptCompileProc (tclEnsemble.c:3298) ==6436== by 0x4E69CE: CompileCmdCompileProc (tclCompile.c:1993) ==6436== by 0x4E703D: CompileCommandTokens (tclCompile.c:2109) ==6436== by 0x4E75B7: TclCompileScript (tclCompile.c:2269) ==6436== by 0x4E4359: TclSetByteCodeFromAny (tclCompile.c:838) ==6436== by 0x511331: TclCompileObj (tclExecute.c:1776) ==6436== by 0x437F1B: TclNREvalObjEx (tclBasic.c:6732) ==6436== by 0x586A40: TclNRUplevelObjCmd (tclProc.c:985) ==6436== by 0x434F7A: Dispatch (tclBasic.c:4997) ==6436== by 0x435002: TclNRRunCallbacks (tclBasic.c:5037) ==6436== by 0x4348CE: Tcl_EvalObjv (tclBasic.c:4756) ==6436== by 0x436F30: TclEvalEx (tclBasic.c:5913) ==6436== by 0x55A0D8: Tcl_FSEvalFileEx (tclIOUtil.c:1782) ==6436== by 0x566B01: Tcl_MainEx (tclMain.c:405) ==6436== by 0x410188: main (tclAppInit.c:94) ==6436== ++++ format-2.19 PASSED looking....
- login: "dgp"
- mimetype: "text/plain"
Ticket change [a6440ba025] (rid 209916) by dgp on 2023-03-08 19:31:51:
- closedate changed to: "2460012.31379317"
- icomment:
In test format-2.19 the access to uninitialized memory happens when generating the string rep of the argument "%s\uDE02". The first two characters are written as single-byte encoded UTF-8 into dst. Then the third character needs to be written starting at the 3rd byte of the string rep. Since the character U+DE02 is a low surrogate, it reads the 3rd and 4th byte to check for residue of a high surrogate, but those bytes are uninitialized. Moving the initialization to \0 inside the loop disrupts the surrogate history mechanism, so that's not an answer. Maybe a conditional initialization is possible, but getting really messy with callers of Tcl_UniCharToUtf() burdened with a lot of specialized knowledge to make the call in ways that reliably avoid this issue.
- login: "dgp"
- mimetype: "text/plain"
Ticket change [c4d8af5223] (rid 210465) by dgp on 2023-03-20 18:46:36:
- closedate changed to: "2460024.28237244"
- icomment:
Candidate fix on a branch for review. Adds initialization to the allocation routine most often at work.
- login: "dgp"
- mimetype: "text/plain"
Ticket change [bbe976c45b] (rid 210706) by jan.nijtmans on 2023-03-22 21:24:53:
- closedate changed to: "2460026.39228056"
- closer changed to: "jan.nijtmans"
- icomment: ""Candidate fix" looks good to me. Thanks!"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"