Skip to content
Tcl Source Code History Of Ticket 167e0635db
Login

History Of Ticket 167e0635db

Artifacts Associated With Ticket 167e0635db

  1. Ticket change [91e157b032] (rid 224318) by dgp on 2024-04-04 23:16:49:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      ==4654== Conditional jump or move depends on uninitialised value(s)
      ==4654==    at 0x44F4EB: ClockParseFmtScnArgs (tclClock.c:3443)
      ==4654==    by 0x44FA4A: ClockFormatObjCmd (tclClock.c:3583)
      ==4654==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==4654==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==4654==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==4654==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==4654==    by 0x57A182: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==4654==    by 0x587D26: Tcl_MainEx (tclMain.c:404)
      ==4654==    by 0x40F3CB: main (tclAppInit.c:94)
      
      
      ...
      
      ==4654== Conditional jump or move depends on uninitialised value(s)
      ==4654==    at 0x551500: CreateHashEntry (tclHash.c:288)
      ==4654==    by 0x453146: FindOrCreateFmtScnStorage (tclClockFmt.c:800)
      ==4654==    by 0x453281: Tcl_GetClockFrmScnFromObj (tclClockFmt.c:864)
      ==4654==    by 0x45740E: ClockGetOrParseFmtFormat (tclClockFmt.c:3132)
      ==4654==    by 0x457A7D: ClockFormat (tclClockFmt.c:3276)
      ==4654==    by 0x44FA84: ClockFormatObjCmd (tclClock.c:3596)
      ==4654==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==4654==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==4654==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==4654==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==4654==    by 0x57A182: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==4654==    by 0x587D26: Tcl_MainEx (tclMain.c:404)
      ==4654==    by 0x40F3CB: main (tclAppInit.c:94)
      ==4654== 
      ==4654== Conditional jump or move depends on uninitialised value(s)
      ==4654==    at 0x551500: CreateHashEntry (tclHash.c:288)
      ==4654==    by 0x453146: FindOrCreateFmtScnStorage (tclClockFmt.c:800)
      ==4654==    by 0x453281: Tcl_GetClockFrmScnFromObj (tclClockFmt.c:864)
      ==4654==    by 0x454FD9: ClockGetOrParseScanFormat (tclClockFmt.c:2080)
      ==4654==    by 0x4558CD: ClockScan (tclClockFmt.c:2286)
      ==4654==    by 0x44FCD9: ClockScanObjCmd (tclClock.c:3686)
      ==4654==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==4654==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==4654==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==4654==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==4654==    by 0x57A182: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==4654==    by 0x587D26: Tcl_MainEx (tclMain.c:404)
      ==4654==    by 0x40F3CB: main (tclAppInit.c:94)
      
      
      ...
      
      ==4654== Conditional jump or move depends on uninitialised value(s)
      ==4654==    at 0x44F4EB: ClockParseFmtScnArgs (tclClock.c:3443)
      ==4654==    by 0x45136A: ClockAddObjCmd (tclClock.c:4436)
      ==4654==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==4654==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==4654==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==4654==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==4654==    by 0x57A182: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==4654==    by 0x587D26: Tcl_MainEx (tclMain.c:404)
      ==4654==    by 0x40F3CB: main (tclAppInit.c:94)
      ==4654== 
      ==4654== Conditional jump or move depends on uninitialised value(s)
      ==4654==    at 0x44F4EB: ClockParseFmtScnArgs (tclClock.c:3443)
      ==4654==    by 0x44FBC4: ClockScanObjCmd (tclClock.c:3660)
      ==4654==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==4654==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==4654==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==4654==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==4654==    by 0x57A182: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==4654==    by 0x587D26: Tcl_MainEx (tclMain.c:404)
      ==4654==    by 0x40F3CB: main (tclAppInit.c:94)
      
    5. foundin initialized to: "9.0b2"
    6. is_private initialized to: "0"
    7. login: "dgp"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "8e2300e85be5dd1445b9666eb9429055951e33be"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "dgp"
    14. subsystem initialized to: "06. Time Measurement"
    15. title initialized to: "`make valgrind` detections"
    16. type initialized to: "Bug"
  2. Ticket change [86c46c3422] (rid 224322) by jan.nijtmans on 2024-04-05 13:00:40:

    1. assignee changed to: "sebres"
    2. icomment:
      This looks like 2 different issues, one of them should be fixed [561cb0ffb298dbc2|here]. @sebres, please review.
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  3. Ticket change [a897fe0011] (rid 224328) by sebres on 2024-04-05 14:46:52:

    1. icomment:
      I an unsure it meant really that, what you were trying to fix.
      
      Conditional jump or move depends on uninitialised value(s) (tclClock.c:3443),
      could mean either baseObj or its content (length/bytes).
      
      However I'd try to check it later (if get valgrind to hand).
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [d53513d79d] (rid 224336) by sebres on 2024-04-05 19:57:32:

    1. icomment:
      Oh... now I followed your approach... however I don't think it is well, because now due to an attempt with Tcl_GetIndexFromObj firstly, it would always try to convert numeric seconds (either regular case) to index (together with conversion numeric to str, etc), what was avoided before.
      
      I could suggest this one:
      
      ```diff
      	if (
      -	    (baseObj->length == 4 && baseObj->bytes && *(baseObj->bytes+1) == 'n') ||
      +	    (baseObj->bytes && baseObj->length == 4 && *(baseObj->bytes+1) == 'n') ||
      
      ```
      But I cannot reproduce it - don't see "Conditional jump or move depends on uninitialised value" at all...
      Everything I see from valgrind is a lot of "X bytes in 1 blocks are still reachable in loss record".
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  5. Ticket change [6b218bd712] (rid 224337) by jan.nijtmans on 2024-04-05 20:57:11:

    1. icomment:
      @sebres, did you time the benefit of your optimization? I don't think it really makes a noticeable difference. The first time Tcl_GetIndexFormObj() is called, it will be converted to 'index' type, yes that takes somewhat more time. But second time and later it's already of 'index' type and that's fast.
      
      So, typical code doing a "clock seconds -now" repeatedly should be very fast anyway.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [87c2a24b6a] (rid 224338) by jan.nijtmans on 2024-04-05 21:01:42:

    1. icomment:
      For the integer case, it could help to check the type: If the type is 'integer' it makes no sense to call Tcl_GetIndexFromObj(). That's a quick check that might make a difference
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [76a40b3dac] (rid 224344) by sebres on 2024-04-05 21:37:56:

    1. icomment:
      @Jan, of course I meant the regular (integer) case.<br/>
      One could surely do it with type-check, as you suggest, however in clockmod (8.6 based) there were several int-types (int32, wide), but with that thing I wanted just fast avoid additional shimmer from whatever type (unicode, string with utf-8, future objects like clock-seconds, etc with theoretic fast conversion to integer), since unneeded shimmer is always bad... Thus it was made how it made.<br/>
      And it is not "optimization", this is very quick and simple trick.
      
      But back to valgrind...<br/>
      I don't follow the first claim:
      
      To have uninitialized value in that condition, `baseObj->length` or `baseObj->bytes` needs to be uninitialized, because `baseObj` is always initialized either within `TclNewObj` & co or to NULL by memset in `ClockInitFmtScnArgs`.
      
      So I don't follow the issue why valgrind may complain.
      
      Also I don't follow the second claim:
      
      To have uninitialized value in CreateHashEntry (tclHash.c:288) from  FindOrCreateFmtScnStorage (tclClockFmt.c:800) the last must use `strFmt` (and related `key`) uninitialized, but it is obtained by `TclGetString(objPtr)` in (tclClockFmt.c:777), so this is basically impossible (unless something makes hash-table corrupt and it is rather `hPtr->key.oneWordValue` in the condition where valgrind complains).
      
      
      ```c
      // tclHash.c:
      
      240 static Tcl_HashEntry *
      241 CreateHashEntry(
      242     Tcl_HashTable *tablePtr,	/* Table in which to lookup entry. */
      243     const char *key,		/* Key to use to find or create matching
      244
      245  				 * entry. */
      ...
      288 	    if ((key == hPtr->key.oneWordValue)
      
      // tclClockFmt.c:
      
      772 static ClockFmtScnStorage *
      773 FindOrCreateFmtScnStorage(
      774     Tcl_Interp *interp,
      775     Tcl_Obj    *objPtr)
      776 {
      777     const char *strFmt = TclGetString(objPtr);
      ...
      800     hPtr = Tcl_CreateHashEntry(&FmtScnHashTable, strFmt, &isNew);
      ```
      
      Bug in valgrind? Bug in 9.0 somewhere?
      Anyway I don't reproduce it, neither for 8.7 nor 9.0 with my valgrind / gcc:
      
      ```
      $ valgrind --version
      valgrind-3.19.0
      $ gcc --version
      gcc (Debian 12.2.0-14) 12.2.0
      ```
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  8. Ticket change [0814a510f9] (rid 224355) by sebres on 2024-04-06 14:04:28:

    1. icomment:
      @dgp, can you please explain how you get it, Don?<br/>
      For instance exact build args (configure/make), CFLAGS, etc... And which versions (valgrind, gcc or clang, platform) did you use?<br/>
      I'm trying desperately to reproduce it and don't see "Conditional jump or move depends on uninitialised value" messages. One can surely rewrite it to avoid that check, but I would like to understand the issue as precise as possible (what exactly causes it, since normally that tcl-objects shall not produce uninitialized values at all, neither literals nor dynamically created objects, so would be nice to know the origin of them).
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  9. Ticket change [016acdaa7c] (rid 224395) by dkf on 2024-04-09 11:28:52:

    1. icomment:
      I suppose the first question is: Which test triggers this behaviour? Being able to trace things from a single test is a lot easier than a whole test file. (If it is many tests, pick one.) If no single test triggers it, it's going to be a lot trickier to hunt down (speaking with experience from TclOO).
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  10. Ticket change [fc60e521d5] (rid 224416) by dkf on 2024-04-09 15:51:20:

    1. icomment:
      Why are you collecting the `baseObj` in the `ClockFmtScnCmdArgs` when it's only ever used in the same function that sets it (`ClockParseFmtScnArgs()`)? It's not even being used to pass between multiple calls of the same function. I'm not sure that it's the problem, but such fields definitely can't be the problem if they don't exist...
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  11. Ticket change [ed6aaa4b7b] (rid 224417) by sebres on 2024-04-09 18:47:11:

    1. icomment:
      > Why are you collecting the `baseObj` in the `ClockFmtScnCmdArgs` when it's only ever used in the same function ...
      
      In my own engine (where I back-ported it from), baseVal (date->seconds) is converted to seconds (and others parts) on demand, e. g. to bypass unneeded conversions through the TZ etc, for instance if the whole date is specified in input string. Also it is used additionally on few other functions, since, on my side, this object is not necessarily an integer but can be clock-seconds (special type), previously got from another clock-scan calls (e. g. to format it or use as another base).<br/>
      Because it was too complex and also too different (since core-tcl's object can shimmer, cannot be converted from some type to integer without interim string-representation etc), I decided not to provide that logic firstly.
      
      However this mentioned "on demand conversion" can be surely done later (e. g. it could speed-up scans like `clock scan "2020-01-01 00:00:00"` with totally unneeded base).
      
      Anyway, I don't think it bothers somehow (moreover may help by some deep debug on a conditional BP etc)... And it's definitely not the problem that valgrind complains, because initially opts.baseObj pointer is 0 (by memset via ClockInitFmtScnArgs) and the supposed place where valgrind means it'd be uninitialized is a condition over content of it (bytes & length), which shall be always initialized in properly created tcl-object (no matter it'd be local or belong to some structure).
      
      As already said it is not explainable to me, and I hoped to reproduce it to go deeper, just unsuccessful.<br/>
      Could you reproduce it with your valgrind, Donal?
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  12. Ticket change [21fa9902e1] (rid 224420) by dkf on 2024-04-10 08:23:37:

    1. icomment:
      > Could you reproduce it with your valgrind, Donal?
      
      I don't have valgrind on this machine at all.
      
    2. login: "dkf"
    3. mimetype: "text/plain"
  13. Ticket change [e4970e7dcb] (rid 224442) by dkf on 2024-04-10 10:43:56:

    1. icomment:
      In any case, the hallmarks of this are of a `Tcl_Obj*` with an uninitialized but non-`NULL` `bytes` field; that would be sufficient to explain this. That is a serious bug... but not (necessarily) in the clock code; those appear to all be values associated with an argument supplied to the command.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  14. Ticket change [577d3f5a6f] (rid 224448) by sebres on 2024-04-10 12:02:51:

    1. icomment:
      Yes, that was my assumption too (therefore I wanted to debug that deeper)...<br/>
      However, before [9d7596c1381ec788] (where Don's valgrind produces the issue) the checks for bytes and length were inverted (length firstly), so if it was not some UB-similar thing by compiler optimization, and was indeed uninitialized length, I tried to rewrite it more similar to macro `TclGetString*` which firstly checks bytes and seems not bother in valgrind. Although 8.7/9.0 tcl-core initializes bytes in TclNewObj or whatever (where they set to `0` and `&tclEmptyString`) or by `TclInitEmptyStringRep`.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  15. Ticket change [89ede3a537] (rid 224449) by sebres on 2024-04-10 12:07:00:

    1. icomment:
      <i>repeated, because of wrong type (Markdown) in previous comment that destroyed it.</i>
      
      Yes, that was my assumption too (therefore I wanted to debug that deeper)...<br/>
      However, before [9d7596c1381ec788] (where Don's valgrind produces the issue) the checks for bytes and length were inverted (length firstly), so if it was not some UB-similar thing by compiler optimization, and was indeed uninitialized length, I tried to rewrite it more similar to macro `TclGetString*` which firstly checks bytes and seems not bother in valgrind. Although 8.7/9.0 tcl-core initializes bytes in TclNewObj or whatever (where they set to `0` and `&tclEmptyString`) or by `TclInitEmptyStringRep`.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  16. Ticket change [7eda870437] (rid 224450) by dkf on 2024-04-10 12:56:16:

    1. icomment:
      Ah yes, `length` is only defined at all if `bytes` is non-`NULL`, just as `internalRep` is only defined if `typePtr` is non-`NULL` (and then you need to know the implementation of the `typePtr` to know how to interpret it). Accessing a non-defined field is the sort of thing that valgrind ought to catch.
      
      I think we can assume that that fixes it, in the absence of further info from dgp (specifically what test triggered it and what fossil ID was tested).
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  17. Ticket change [527bd07275] (rid 224467) by sebres on 2024-04-10 14:37:34:

    1. icomment:
      Sure, but (as already wrote) it doesn't explain the second case (in CreateHashEntry/FindOrCreateFmtScnStorage) and ...
      
      > Ah yes, length is only defined at all if bytes is non-NULL
      
      Well, not really - I did not found any place where length may remain uninitialized (let alone [it is always set to 0 by new object](./info?name=590a08c0600261fd0bfeca2619b1da30ef93af15f4f18d1da4cc9f2da2148400&ln=4022)).
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  18. Ticket change [8bbb7763e1] (rid 224502) by dgp on 2024-04-10 15:43:06:

    1. icomment:
      
      Much improved results from changes so far.  Here are remaining reports:
      
      $ make valgrind TESTFLAGS="-file clock.test -verbose bpste"
      ...
      ---- clock-5.1.vm:0 start
      ==32290== Conditional jump or move depends on uninitialised value(s)
      ==32290==    at 0x5514D3: CreateHashEntry (tclHash.c:288)
      ==32290==    by 0x453119: FindOrCreateFmtScnStorage (tclClockFmt.c:799)
      ==32290==    by 0x453254: Tcl_GetClockFrmScnFromObj (tclClockFmt.c:863)
      ==32290==    by 0x4573E1: ClockGetOrParseFmtFormat (tclClockFmt.c:3131)
      ==32290==    by 0x457A50: ClockFormat (tclClockFmt.c:3275)
      ==32290==    by 0x44FA4B: ClockFormatObjCmd (tclClock.c:3599)
      ==32290==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==32290==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==32290==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==32290==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==32290==    by 0x57A155: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==32290==    by 0x587CF9: Tcl_MainEx (tclMain.c:404)
      ==32290==    by 0x40F3CB: main (tclAppInit.c:94)
      ==32290== 
      ++++ clock-5.1.vm:0 PASSED
      ...
      ---- clock-28.1.vm:0 start
      ==32290== Conditional jump or move depends on uninitialised value(s)
      ==32290==    at 0x5514D3: CreateHashEntry (tclHash.c:288)
      ==32290==    by 0x453119: FindOrCreateFmtScnStorage (tclClockFmt.c:799)
      ==32290==    by 0x453254: Tcl_GetClockFrmScnFromObj (tclClockFmt.c:863)
      ==32290==    by 0x454FAC: ClockGetOrParseScanFormat (tclClockFmt.c:2079)
      ==32290==    by 0x4558A0: ClockScan (tclClockFmt.c:2285)
      ==32290==    by 0x44FCA0: ClockScanObjCmd (tclClock.c:3689)
      ==32290==    by 0x4373A0: Dispatch (tclBasic.c:4608)
      ==32290==    by 0x437404: TclNRRunCallbacks (tclBasic.c:4624)
      ==32290==    by 0x436CE3: Tcl_EvalObjv (tclBasic.c:4367)
      ==32290==    by 0x439464: TclEvalEx (tclBasic.c:5463)
      ==32290==    by 0x57A155: Tcl_FSEvalFileEx (tclIOUtil.c:1790)
      ==32290==    by 0x587CF9: Tcl_MainEx (tclMain.c:404)
      ==32290==    by 0x40F3CB: main (tclAppInit.c:94)
      ==32290== 
      ++++ clock-28.1.vm:0 PASSED
      ...
      
      
      At the end are several warnings about read and write after free
      by ClockFmtObj_FreeInternalRep()
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  19. Ticket change [ca4bdd1023] (rid 224503) by sebres on 2024-04-10 16:01:35:

    1. icomment:
      I still don't get it, Don...
      
      How look the configure options? zip-enabled? memdebug?
      
      What is CC (gcc or clang), CFLAGS etc?
      
      Which versions (platform, gcc/clang, valgrind)? I provided my versions below.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  20. Ticket change [a04c223b50] (rid 224506) by dgp on 2024-04-10 16:43:56:

    1. icomment:
      
      Also involved is test clock-1.3.
      
      The common feature is a -format value that is an empty string literal.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  21. Ticket change [f8ec68fbe2] (rid 224527) by sebres on 2024-04-10 22:44:27:

    1. icomment:
      I could surely try to fix it blind again and again...
      
      But why can't I reproduce it?
      
      Here is [a gist how I made it](https://gist.github.com/sebres/764f1c871a52a122d5bec557a6a79d9c) with an output [1.txt](https://gist.github.com/sebres/764f1c871a52a122d5bec557a6a79d9c/raw/34e97f833b49a272a486cd70c19d7193b35b0850/1.txt) generated by test.
      
      Nothing what you observe.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  22. Ticket change [ed077a4f9e] (rid 224528) by sebres on 2024-04-10 23:12:54:

    1. icomment:
      If I try with symbols=mem, I get this summary (but also no one error you posted before):
      
      ```
      $ ../configure --enable-64bit --enable-symbols=mem
      $ make valgrind TESTFLAGS="-file clock.test -verbose bpste" >1.txt 2>&1
      ...
      
      ==11046== LEAK SUMMARY:
      ==11046==    definitely lost: 0 bytes in 0 blocks
      ==11046==    indirectly lost: 0 bytes in 0 blocks
      ==11046==      possibly lost: 0 bytes in 0 blocks
      ==11046==    still reachable: 3,960,225 bytes in 25,518 blocks
      ==11046==         suppressed: 0 bytes in 0 blocks
      ==11046== 
      ==11046== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
      ```
      
      And also tried both with and without zipfs, for x64 and x86, for \*nix & windows in several boxes, it changes nothing on the result...
      
      I don't get it, simply.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  23. Ticket change [4842490118] (rid 224529) by chw on 2024-04-10 23:34:42:

    1. icomment:
      Not that I in detail followed your conversation but
      am impressed of the puzzle which comes up.
      
      It seems to be a good path to define an exact testing
      ground for both (and any) of you in terms of
      
      a) which linux
      b) which cpu and of course
      d) finally forget c) (that's me).
      
    2. login: "chw"
    3. mimetype: "text/plain"
  24. Ticket change [6f607504fa] (rid 224719) by dgp on 2024-04-12 19:25:46:

    1. icomment:
      
      See branch dgp-bug-167e0635db for a patch to remove the last
      round of "Conditional jump" reports from valgrind.
      
      Now looking into the read/write after free troubles....
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  25. Ticket change [90714f2b4f] (rid 224722) by dgp on 2024-04-12 19:38:51:

    1. icomment:
      
      Applied a crude protection against accessing the fss storages
      after a finalization pass has already freed them.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  26. Ticket change [4706ae9267] (rid 224727) by dgp on 2024-04-12 19:55:25:

    1. icomment: "Two memleaks also plugged on that branch."
    2. login: "dgp"
    3. mimetype: "text/plain"
  27. Ticket change [7aedded012] (rid 224728) by sebres on 2024-04-12 19:58:13:

    1. icomment:
      Related to [0e273ad998f16100](./info/0e273ad998f16100)
      
      [Tcl_HashEntry::key](./file?ci=tip&name=generic/tcl.h&ln=1082-1090) is a union.
      So the key.string and key.oneWordValue pointing to the same memory.
      
      The next line (with memcpy) overwrites the same memory block (size is always larger than 1):
      ```
          hPtr->key.oneWordValue = 0; /* See Ticket [167e0635db] */
          memcpy(&hPtr->key.string, string, size);
      ```
      
      Your valgrind seems to be broken, Don.
      
      Or it is some weird constellation (strange alignment or similar thing) on this system, so sizeof and co going confused somewhere. What platform is it actually?
      
      However size is just strlen + 1. Therefore I can only repeat, that valgrind seems to claim nonsense here.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  28. Ticket change [b00c2894d8] (rid 224729) by dgp on 2024-04-12 20:19:38:

    1. icomment:
      
      I see the problems arise when the format string is an empty string.
      Tests clock-1.3, clock-5.1, clock-28.1
      
      When the format string is empty, the value of size is 1.  It is not
      larger than 1.  Does that explain anything?
      
      I would expect the memcpy to copy a single NUL byte into the
      hPtr->key.string field.
      
      I don't know whether that should cause valgrind to think that
      the multi-byte hPtr->key.oneWordValue field is initialized.
      
      This is a CentOS Linux 7.9.2009 system.  The valgrind program
      I am running claims to be version valgrind-3.15.0
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  29. Ticket change [5017db1dfd] (rid 224730) by sebres on 2024-04-12 20:23:13:

    1. icomment:
      Hmm...
      
      CreateHashEntry may have a bug [here](./file?ci=tip&name=generic/tclHash.c&ln=288-289).<br/>
      Or at least it is strange behaviour.
      
      And it doesn't complain in AllocStringEntry just because of [memset here](./file?ci=tip&name=generic/tclHash.c&ln=767).
      
      
      It could be partially mea culpa - blame shows [273d53b2e7567430](./info/273d53b2e7567430) - and it is correct for pointers (or Tcl_Obj), but for key.string it doesn't look correct to me. Shame on me (my fork shows completely different algorithm, so I overlooked something by backporting).
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  30. Ticket change [4b9bac1bee] (rid 224731) by jan.nijtmans on 2024-04-12 20:26:30:

    1. icomment:
      What if size < sizeof(hPtr->key.oneWordValue)?
      
      Then, not the whole union is initialized, that's what valgrind is reporting. sizeof(hPtr->key.oneWordValue) will normally be 4 or 8.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  31. Ticket change [bd08aab11f] (rid 224732) by dgp on 2024-04-12 20:28:56:

    1. icomment:
      The routine ClockFmtScnStorageAllocProc also has a memset() call.
      
      I did not attempt to review the calculations of allocsize.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  32. Ticket change [626feebfd5] (rid 224733) by sebres on 2024-04-12 20:29:30:

    1. icomment:
      Oh yes... I had a flags by `Tcl_HashTable`, which allows the direct key compare, otherwise only compares via `compareKeysProc`.<br/>
      Tcl-Core doesn't have it (and it's public interface)...
      
      Looking now how one can fix that bug without that.
      
    2. login: "sebres"
    3. mimetype: "text/x-markdown"
  33. Ticket change [c0ff1e8d1e] (rid 224734) by sebres on 2024-04-12 20:31:06:

    1. icomment:
      It is definitely a bug in tclHash, not in tclClockFmt. So I'll try to fix it (without mentioned flag for hash-table).
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  34. Ticket change [f07dffe087] (rid 224765) by sebres on 2024-04-12 22:24:05:

    1. icomment:
      The bug in tclHash is ultimately fixed now across all affected branches:<br/>
      8.5 - [969a185ea4d19037] to 9.0 - [c3c498a6a853f3b8].
      
      This was really heavy bug - create/find hash entry had mistakenly compare pointer with a content, invalid for all non-pointer hash-types, containing data (strings/arrays) directly in the hash key.
      
      Well, fortunately Dons valgrind was better than my, and finally it came to light...
      And thanks for your obstinacy, Don.
      
      I'm also sure the complain would disappear now (also without [0e273ad998f16100]).
      
      > <i>The routine ClockFmtScnStorageAllocProc also has a memset() call.</i>
      
      This memset only resets the part responsible for ClockFmtScnStorage... 
      So after all by empty format (1 byte long, NTS) it contains 3 (x86) or 7 (x64) uninitialized bytes in key.
      (And it was a good thing, otherwise that bug would be never found and caused extremely rare heisenbug on some constellation for containing data key types).
      
      
      > <i>I did not attempt to review the calculations of allocsize.</i>
      
      Everything must be correct there, but I could rewrite it more clear.
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  35. Ticket change [fae5b9652f] (rid 224858) by dgp on 2024-04-15 17:08:55:

    1. icomment:
      
      I am still trying to digest the full impact of this change, but I can
      report that it seems to have corrected the problem seen in
      Ticket [167e0635db] as well.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  36. Ticket change [cdf5fbf5d2] (rid 224932) by sebres on 2024-04-17 15:20:08:

    1. closedate changed to: "2460418.13898926"
    2. closer changed to: "sebres"
    3. icomment:
      merged (in 9.0 and backported to 8.7), thus close it for now
      
    4. login: "sebres"
    5. mimetype: "text/x-markdown"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"