Tcl Source Code

View Ticket
Login
Ticket UUID: 1fe745559aed47f050b3ba7a5adfae8511bc0a56
Title: 8.7, 9.0: Conditional jump or move depends on uninitialised value in Tcl_UniCharToUtf
Type: Bug Created on: 2022-02-07 14:26:39
Submitter: pointsman Assigned to: jan.nijtmans
Subsystem: 44. UTF-8 Strings Severity: Minor
Priority: 5 Medium Last modified: 2022-02-07 22:22:48
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2022-02-07 22:22:48
Version: 8.7, 9.0
Description:
This script:

foreach str {
    \uD802
} {
    puts [string length $str]
}

running under valgrind with a -DPURIFY 8.7 or 9.0 build (both current branch head)
reports:

 Conditional jump or move depends on uninitialised value(s)
    at 0x4DFD828: Tcl_UniCharToUtf (tclUtf.c:234)
    by 0x4DCD952: TclParseBackslash (tclParse.c:955)
    by 0x4E00DA8: TclCopyAndCollapse (tclUtil.c:806)
    by 0x4DBAD22: SetListFromAny (tclListObj.c:2087)
    by 0x4DB7BBA: TclListObjCopy (tclListObj.c:433)
    by 0x4CA5B11: EachloopCmd (tclCmdAH.c:2681)
    by 0x4CA5673: TclNRForeachCmd (tclCmdAH.c:2577)
    by 0x4C8EB4B: Dispatch (tclBasic.c:4923)
    by 0x4C8EBD1: TclNRRunCallbacks (tclBasic.c:4963)
    by 0x4C8E499: Tcl_EvalObjv (tclBasic.c:4682)
    by 0x4C90950: TclEvalEx (tclBasic.c:5838)
    by 0x4DB0C85: Tcl_FSEvalFileEx (tclIOUtil.c:1782)
  Uninitialised value was created by a heap allocation
    at 0x4A34E6D: malloc (vg_replace_malloc.c:309)
    by 0x4C81F7F: TclpAlloc (tclAlloc.c:699)
    by 0x4DC8296: Tcl_InitStringRep (tclObj.c:1824)
    by 0x4DBAC88: SetListFromAny (tclListObj.c:2075)
    by 0x4DB7BBA: TclListObjCopy (tclListObj.c:433)
    by 0x4CA5B11: EachloopCmd (tclCmdAH.c:2681)
    by 0x4CA5673: TclNRForeachCmd (tclCmdAH.c:2577)
    by 0x4C8EB4B: Dispatch (tclBasic.c:4923)
    by 0x4C8EBD1: TclNRRunCallbacks (tclBasic.c:4963)
    by 0x4C8E499: Tcl_EvalObjv (tclBasic.c:4682)
    by 0x4C90950: TclEvalEx (tclBasic.c:5838)
    by 0x4DB0C85: Tcl_FSEvalFileEx (tclIOUtil.c:1782)
User Comments:
jan.nijtmans added on 2022-02-07 15:36:11:

Proposed fix (8.7) here: [4e0909a17e33629c]

Thanks for the report!


pointsman added on 2022-02-07 21:20:23:
Yes, with [4e0909a17e33629c] valgrind doesn't complain about this anymore. Seems this was it.

For the record, I must have botched my test script, while minimizing it. At least I don't see the valgrind report anymore with the original test script with core-8-branch. But I see it with this one:

foreach str {
    \uDFFF
} {
    puts [string length $str]
}

While this shows the problem relibale with 8.7 it is gone with [4e0909a17e33629c].

jan.nijtmans added on 2022-02-07 22:22:48:

Merged now to core-8-branch and trunk. Closing.

Thanks for your confirmation that it's now fixed!