Skip to content
Tcl Source Code History Of Ticket 9a2351225c
Login

History Of Ticket 9a2351225c

Artifacts Associated With Ticket 9a2351225c

  1. Ticket change [b117645985] (rid 240827) by jan.nijtmans on 2025-06-03 16:34:05:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      See: [https://github.com/tcltk/tcl/actions/runs/15411189741]
      
      Breakage appears to start with [a8d25c2bb06105ab|this] commit: Upgrade \[lappend\] so it bytecode compiles directly with expansion of arguments
      
    5. foundin initialized to: "trunk"
    6. is_private initialized to: "0"
    7. login: "jan.nijtmans"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "0c50e5320704d174412e57b873d8932de15303e0"
    10. resolution initialized to: "None"
    11. severity initialized to: "Critical"
    12. status initialized to: "Open"
    13. submitter initialized to: "jan.nijtmans"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to: "32-bit build broken"
    16. type initialized to: "Bug"
  2. Ticket change [4d6cd0a74c] (rid 240829) by jan.nijtmans on 2025-06-03 17:27:48:

    1. assignee changed to: "dkf"
    2. icomment:
      Proposed fix [2456cb07e880c9c7|here], simply by reverting the commit that caused it.
      
      Can be re-applied after the problem is fixed.
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  3. Ticket change [09ddd7df33] (rid 240840) by apnadkarni on 2025-06-04 05:57:48:

    1. icomment:
      (moved from duplicate ticket)
      
      Github CI shows the following test failure:
      
      ```
       ==== lseq-bug-54329e39c7 does not cause memory bloat FAILED
      ==== Contents of test case:
      
          set l [lseq 1000000]
          proc p l {foreach x $l {}}
          set premem [memusage]
          p $l
          set postmem [memusage]
          expr {[string match *purify* [tcl::build-info]] || ($postmem - $premem < 10) ? 1 : ($postmem - $premem)}
      
      ---- Result was:
      36
      ---- Result should have been (exact matching):
      1
      ==== lseq-bug-54329e39c7 FAILED
      ```
      
      The configuration it fails on is Linux gcc `configure CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit`. Other Linux configurations are aborted when this run fails so it is not clear if they would also fail.
      
      The failures started happening somewhere after [0ae5d5f12e847c50](https://core.tcl-lang.org/tcl/info/0ae5d5f12e847c50). Unfortunately since fossil->github CI updates are batched, and I cannot reproduce the failure on my system, I cannot tell when it started happening.
      
      It is also possible that the test itself is flawed. It checks for increase in memory usage and it is possible the new byte code uses a little more than expected on this test. But that is pure speculation on my part.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  4. Ticket change [51bb0390ad] (rid 240843) by apnadkarni on 2025-06-04 06:21:21:

    1. login: "apnadkarni"
    2. mimetype: "text/plain"
    3. title changed to:
      32-bit build broken (test lseq-bug-54329e39c7 fails)
      
  5. Ticket change [8ba00c0166] (rid 240851) by dkf on 2025-06-04 08:07:24:

    1. icomment:
      The problem is more likely in the `INST_LAPPEND_LIST` implementation, which that code causes to become more exercised.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  6. Ticket change [605a050961] (rid 240852) by dkf on 2025-06-04 08:10:44:

    1. icomment:
      OTOH, why is a change to the `lappend` compiler causing a memory leak in code that doesn't (appear) to call that command?! That makes no sense...
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  7. Ticket change [07702d216f] (rid 240853) by jan.nijtmans on 2025-06-04 08:45:33:

    1. icomment:
      @dkf, do you have (or can you work on) a better fix? trunk shouldn't be in the broken state for more than a few days.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [59fa2226b2] (rid 240854) by dkf on 2025-06-04 09:00:45:

    1. icomment:
      Have you confirmed that that commit fixes anything? I don't see that tag being run. (I also cannot run locally in that mode.)
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  9. Ticket change [63b95cef4f] (rid 240855) by dkf on 2025-06-04 09:15:41:

    1. icomment:
      Hmm, the `memusage` command called by that test has a resource leak. The `fd` is never closed.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  10. Ticket change [9d162b01a0] (rid 240856) by apnadkarni on 2025-06-04 09:55:41:

    1. icomment:
      dkf> OTOH, why is a change to the `lappend` compiler causing a memory leak in code that doesn't (appear) to call that command?! That makes no sense...
      
      Yes, that is exactly what I wondered too. Also, it may not be a memory *leak* per se but rather more memory used (that gets freed eventually when the lseq goes out of scope). Iirc, it internally builds a Tcl_Obj array on a Tcl_ListObjGetElements call. That test was intended to ensure that does not happen on simple iteration. It's hard to see why lappend compilation changes would cause that to happen.
      
      dkf> Have you confirmed that that commit fixes anything? I don't see that tag being run. 
      
      I guess that tag was pushed too late for the current CI runs. The first CI run that failed included multiple fossil commits so difficult to tell immediately which one caused the failure. It is possible one of the other check-ins in that run caused the failure. I guess we will know after the next set of runs.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  11. Ticket change [f1b3b7582c] (rid 240857) by dkf on 2025-06-04 09:56:01:

    1. icomment:
      Without knowing the page size, it's hard to say just how much is used extra. Or if that's a problem. (At a guess, it might be deciding to convert the arith-series to a base list, but I don't see why. Checking for that would be easy to add to the test.)
      
      But I'm very concerned that you're blaming changes to `lappend` for alterations in memory usage of code that doesn't touch that command, especially without evidence that the backout of the change you're blaming resolves the problem (because those builds just aren't even being scheduled to run despite having what appears to be the right tag). I just don't see how that commit could possibly cause this; it makes _no_ sense at all.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  12. Ticket change [382c9e8fb3] (rid 240858) by apnadkarni on 2025-06-04 10:00:43:

    1. icomment:
      The only other significant commit in prior to the breakage is the TIP 716 merge but it's even harder to imagine how that might have broken that test!
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  13. Ticket change [33d620c981] (rid 240859) by dkf on 2025-06-04 10:02:36:

    1. icomment:
      Ah, I see what the problem is. We've hit the usage limits.
      
      I'm going to have to disable most workflow jobs, especially on Windows, to free up resources for future testing. **You have been told about this before.** Only Linux may have large numbers of jobs, precisely because it is the cheapest option.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  14. Ticket change [6edb90e03e] (rid 240860) by jan.nijtmans on 2025-06-04 10:05:04:

    1. icomment:
      I prefer a 'real' solution over a simple backout. But if the trunk stays 'broken' for more than a few days, we have to do something.
      
      It makes no sense to me either.
      
      I don't know why the 'core-*' tags didn't build. That would have given proof which commit was to 'blame'
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  15. Ticket change [d9c2698fa1] (rid 240889) by dkf on 2025-06-04 11:01:20:

    1. icomment:
      I completely agree that this is serious. I'm just stuck on 64-bit Windows where I really cannot run that config myself. `;-)`
      
      Assuming I've not made a catastrophic blunder, I've turned down the size of the build matrices for the tags, which will start to recover resources. (Computed build matrices are a new departure for me.)
      
      ----
      
      Evidence that I do have:
      
      ```
      % eval {
          set l [lseq 1000000]
          proc p l {foreach x $l {}}
      }
      % repr $l
      value is a arithseries with a refcount of 4, object pointer at 0x23b521a96b8, internal representation 0x23b521a97b8:0x0, no string representation
      % memory info
      total mallocs                 171310
      total frees                   157962
      current packets allocated      13348
      current bytes allocated       873015
      maximum packets allocated      13580
      maximum bytes allocated       913761
      
      % p $l
      % repr $l
      value is a arithseries with a refcount of 4, object pointer at 0x23b521a96b8, internal representation 0x23b521a97b8:0x0, no string representation
      % memory info
      total mallocs                3173083
      total frees                  3159678
      current packets allocated      13405
      current bytes allocated       876104
      maximum packets allocated      13580
      maximum bytes allocated       913761
      
      % proc p2 l {foreach x $l {set y [memory info]};return $y}
      % p2 $l
      total mallocs              148173686
      total frees                148160185
      current packets allocated      13501
      current bytes allocated       880819
      maximum packets allocated      13580
      maximum bytes allocated       913761
      
      % unset l
      % memory info
      total mallocs              148174291
      total frees                148160792
      current packets allocated      13499
      current bytes allocated       881069
      maximum packets allocated      13580
      maximum bytes allocated       913761
      ```
      This shows that we're not getting excess memory usage at least on this platform.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  16. Ticket change [5668c45590] (rid 240892) by dkf on 2025-06-04 13:52:58:

    1. icomment:
      Looking at what the failing test does, reworking to use `memory info` is probably the best option anyway. The test is looking to verify that `foreach` doesn't force an arithmetic series object to fully instantiate... which is good, but it's doing it by using a proxy measure that could be confounded by other effects, to which it thus becomes very sensitive. The fact that it's using `[tcl::build-info purify]` as a condition to make the test meaningless is a sign that things are not healthy.
      
      ----
      
      The proof that there's nothing bad happening in the interaction between `foreach` and `lseq` is in this (with `p1` and `p2` pre-declared/executed to ensure the bytecode's already there):
      
      ```
      % proc p1 l {foreach x $l {}}
      % proc p2 l {foreach x [list 0 {*}$l] {}}
      % p1 1
      % p2 1
      % memory info
      total mallocs                 146292
      total frees                   133476
      current packets allocated      12816
      current bytes allocated       818998
      maximum packets allocated      13019
      maximum bytes allocated       853114
      
      % p1 [lseq 1 1000000]; memory info
      total mallocs                3146737
      total frees                  3133899
      current packets allocated      12838
      current bytes allocated       820140
      maximum packets allocated      13019
      maximum bytes allocated       853114
      
      % p2 [lseq 1 1000000]; memory info
      total mallocs                6147179
      total frees                  6134325
      current packets allocated      12854
      current bytes allocated      9201511
      maximum packets allocated    3012872
      maximum bytes allocated    141202167
      
      ```
      Notably, the expansion of the sequence to make a standard list (plus one element) results in a vastly higher peak memory usage, as expected.
      
      And I'm concerned that there's so much memory still allocated in this case. There appears to be a leak!
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  17. Ticket change [eb44b46c13] (rid 240893) by dkf on 2025-06-04 13:54:40:

    1. login: "dkf"
    2. mimetype: "text/plain"
    3. priority changed to: "8"
    4. subsystem changed to: "47. Bytecode Compiler"
  18. Ticket change [b713fb4153] (rid 240910) by apnadkarni on 2025-06-04 15:39:49:

    1. icomment:
      @dkf - trying your p1/p2 with a valgrind build shows no memory leaks, and no difference between 9.0.1 and the trunk. So I don't think it is a leak in terms of lost memory. Nevertheless, that max memory allocated is strange because even if the lseq fully instantiated, it should not go THAT high even if the string form has to be generated along the way. As an aside, there are several places in the TEBCresume where abstract lists are instantiated via TclListObjElements where they need not be; it's on my todo list once things settle down.
      
      The other mildly curious thing is that the 64-bit runs do not fail (well, they are aborted because the 32-build failed but logs show they ran successfully). Of course, memory management in 64-bit could be quite different.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  19. Ticket change [5cc281bb89] (rid 240911) by jan.nijtmans on 2025-06-05 07:55:59:

    1. icomment:
      Building now gives:
      <pre>
      Invalid workflow file: .github/workflows/win-build.yml#L122
      The workflow is not valid. .github/workflows/win-build.yml (Line: 122, Col: 17): Unrecognized named-value: 'need'. Located at position 10 within expression: fromJson(need.plan.outputs.gcc) .github/workflows/win-build.yml (Line: 122, Col: 17): Unexpected value '${{ fromJson(need.plan.outputs.gcc) }}'
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  20. Ticket change [e978ab23d1] (rid 240912) by jan.nijtmans on 2025-06-05 07:56:47:

    1. icomment:
      Building now gives:
      <pre>
      Invalid workflow file: .github/workflows/win-build.yml#L122
      The workflow is not valid. .github/workflows/win-build.yml (Line: 122, Col: 17): Unrecognized named-value: 'need'. Located at position 10 within expression: fromJson(need.plan.outputs.gcc) .github/workflows/win-build.yml (Line: 122, Col: 17): Unexpected value '${{ fromJson(need.plan.outputs.gcc) }}'
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  21. Ticket change [05e8d8987c] (rid 240913) by dkf on 2025-06-05 08:00:06:

    1. icomment:
      @apnadkarni `p2` is _designed_ to force things to a list; by comparing it with `p1`, I can see that `p1` isn't converting. The number of allocs is going to be large in both cases because there's all those temporary items for the members of the sequence, but they should all be released again and cause no problems.
      
      > I'm much more concerned by the "current bytes allocated" figure in the `p2` case; the memory (either from the sequence or its copy) shouldn't be still being held. OTOH, it's strictly beyond the scope of the original test. New test case?
      >
      > Out of scope of this issue.
      
      I think we can rewrite the failing test to use `memory info` and get a more reliable result that works across all platforms and doesn't have that "interesting" purify exception. I suspect we'll need to run it in a subprocess for that to really work, as we're not just interested in leaks but also in peak allocations.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  22. Ticket change [c00ba77790] (rid 240919) by dkf on 2025-06-05 08:02:48:

    1. icomment: "@jan.nijtmans Fixed."
    2. login: "dkf"
    3. mimetype: "text/plain"
  23. Ticket change [8d1f59f627] (rid 240928) by dkf on 2025-06-05 08:47:10:

    1. icomment:
      I've suggested an alternate test here: [branch: lseq-no-bloat-test](https://core.tcl-lang.org/tcl/timeline?r=lseq-no-bloat-test). It uses the peak memory usage data out of `memory info` in a fresh interpreter, so it should be pretty reliable (and not sensitive to the OS). If I alter the code to force a conversion of the sequence to a list (_à la_ `p2`) then it shows up _very_ visibly.
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  24. Ticket change [e6cbec9e3c] (rid 240931) by apnadkarni on 2025-06-05 13:47:32:

    1. icomment:
      I am ok with the alternate test if you think it is more suitable. My preference for statm was simply because it did not require a --enable-symbols=mem build. On the other hand, as you say it is platform specific so there's that.
      
      I'm still mystified as to why it triggered though...
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  25. Ticket change [22ded25e65] (rid 240943) by dkf on 2025-06-05 14:59:54:

    1. icomment:
      > I'm still mystified as to why it triggered though...
      
      It's a puzzler to me too.
      
      About the only possibility I can think of would be if things somehow triggered a new tranche of underlying memory blocks to be allocated for `Tcl_Alloc` and/or `TclStackAlloc`, but if that's what's being seen then it's small wonder that it isn't triggering for 64-bit (which probably uses different block sizes). I don't know if that fits the description of there being 36 more pages in use; I don't even know how much space 36 pages is on that system.
      
      But if that's it, then it's not a bug and not indicative of the `lseq` failure the test is looking for, which shows up as needing space for a million new `Tcl_Obj` instances (minimum 24MB on 32-bit systems). I certainly don't believe that pages are as large as 650kB on _any_ system deployed anywhere...
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  26. Ticket change [b3496dd1d5] (rid 240955) by dkf on 2025-06-06 08:44:45:

    1. icomment:
      I believe this is now resolved... by changing how we do that test to use the peak memory usage field from `memory info`; that's more stable, and runs on more platforms.
      
      The fundamental problem was I couldn't correlate a 36 page increase in memory usage to _anything_ in the changes between a passing and failing test. It was all too far into the realm of "I guess that's maybe not a bug". It sure wasn't due to allocating array of a million pointers to back a list...
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
    4. status changed to: "Pending"
  27. Ticket change [f7a137b2ed] (rid 240957) by jan.nijtmans on 2025-06-06 08:56:41:

    1. icomment:
      <pre>
      Run case "$GITHUB_REF_NAME" in
        case "$GITHUB_REF_NAME" in
          "main" | "core-9-0-branch")
            cat >>$GITHUB_OUTPUT <<'EOF'
            gcc=<<'EOJ'
            {
              "config": [
                "",
                "CFLAGS=-DTCL_NO_DEPRECATED=1",
                "--disable-shared",
                "--disable-zipfs",
                "--enable-symbols",
                "--enable-symbols=mem",
                "--enable-symbols=all",
                "CFLAGS=-ftrapv",
                "CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit"
              ]
            }
            EOJ
            EOF
            ;;
          *)
            cat >>$GITHUB_OUTPUT <<'EOF'
            gcc=<<'EOJ'
            {
              "config": [
                "",
                "--enable-symbols=all",
                "CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit"
              ]
            }
            EOJ
            EOF
            ;;
        esac
        shell: /usr/bin/bash -e {0}
      /home/runner/work/_temp/e2249492-f7ea-4ba7-9b51-9b9f2394f87a.sh: line 34: warning: here-document at line 3 delimited by end-of-file (wanted `EOF')
      /home/runner/work/_temp/e2249492-f7ea-4ba7-9b51-9b9f2394f87a.sh: line 35: syntax error: unexpected end of file
      Error: Process completed with exit code 2.
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  28. Ticket change [e7b562eab2] (rid 241002) by dkf on 2025-06-06 13:35:33:

    1. icomment:
      I was already fixing that. It's now sorted (and tested in a private repo, so I _know_ it work).
      
    2. login: "dkf"
    3. mimetype: "text/x-markdown"
  29. Ticket change [147bf1ddc2] (rid 241251) by jan.nijtmans on 2025-06-12 16:20:52:

    1. closedate changed to: "2460839.18116659"
    2. closer changed to: "jan.nijtmans"
    3. login: "jan.nijtmans"
    4. mimetype: "text/plain"
    5. resolution changed to: "Fixed"
    6. status changed to: "Closed"