Tcl Source Code

View Ticket
Login
Ticket UUID: 5f236bc67afef5e01f786d1ad93e9a0759b575f4
Title: valgrind report for Tcl_UniCharToUtf
Type: Bug Created on: 2019-12-09 07:42:21
Submitter: chw Assigned to: jan.nijtmans
Subsystem: 44. UTF-8 Strings Severity: Important
Priority: 5 Medium Last modified: 2019-12-11 09:00:22
Status: Closed Closed by: jan.nijtmans
Resolution: Fixed Closed on: 2019-12-11 09:00:22
Version: core-8-branch
Description:
Sorry for being a PITA, here is another test case:

1. build a core-8-branch tclsh (x86_64, linux, static, symbols, purify, standard TCL_UTF_MAX=3)

2. run it interactively in
     valgrind --track-origins=yes --leak-check=full -v ...

3. type at tclsh's prompt
     puts "\udcdc\ud8d8\ueeee"

4. observe immediately

==22743== Conditional jump or move depends on uninitialised value(s)
==22743==    at 0x296323: Tcl_UniCharToUtf (tclUtf.c:159)
==22743==    by 0x1FCCF5: UtfToUtfProc (tclEncoding.c:2425)
==22743==    by 0x1FC9BA: UtfIntToUtfExtProc (tclEncoding.c:2247)
==22743==    by 0x1FB2AE: Tcl_UtfToExternal (tclEncoding.c:1477)
==22743==    by 0x23898B: Write (tclIO.c:4336)
==22743==    by 0x2386AA: Tcl_WriteObj (tclIO.c:4208)
==22743==    by 0x242674: Tcl_PutsObjCmd (tclIOCmd.c:183)
==22743==    by 0x135EE6: Dispatch (tclBasic.c:4811)
==22743==    by 0x135F6C: TclNRRunCallbacks (tclBasic.c:4851)
==22743==    by 0x138912: TclEvalObjEx (tclBasic.c:6420)
==22743==    by 0x1388A6: Tcl_EvalObjEx (tclBasic.c:6401)
==22743==    by 0x2FDC56: Tcl_RecordAndEvalObj (tclHistory.c:189)
==22743==  Uninitialised value was created by a heap allocation
...

5. repeat step 3, no more valgrind complaints seen
User Comments:
jan.nijtmans added on 2019-12-09 19:38:30:

No problem. My original intention was to make core-8-6-branch work fine with TCL_UTF_MAX=3, and core-8-branch with TCL_UTF_MAX=4|6. But ... while backporting things to core-8-6-branch I might as well make it work for all TCL_UTF_MAX values gradually.

I think I got everything covered now in [3e0a616f7e9bf5a2]. I'll see if I can test it with Valgrind.

Thanks!


jan.nijtmans added on 2019-12-11 09:00:22:

Looks like valgrind is satisfied now.

Thanks for persuing this!