Skip to content
Tcl Source Code History Of Ticket 4f6a1ebd64
Login

History Of Ticket 4f6a1ebd64

Artifacts Associated With Ticket 4f6a1ebd64

  1. Ticket change [fcd4c610d1] (rid 158917) by pooryorick on 2017-11-25 15:41:13:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      The following example causes a segmentation fault:
      
      <code><verbatim>
      namespace eval n {namespace ensemble create}
      dict set list one ::two
      namespace ensemble configure n -subcommands $list -map $list
      n one
      </verbatim></code>
      
      The problem is that <code>tclEnsemble.c/BuildEnsembleConfig</code>
      [https://core.tcl.tk/tcl/artifact?ln=2536-2537&name=9cf6780328312995|gets
      hold of a List internal representation] of
      <code>ensemblePtr->subcommandList</code>, but then
      [https://core.tcl.tk/tcl/artifact?ln=2556-2557&name=9cf6780328312995|converts
      the internal representation] of <code>ensemblePtr->subcommandList</code> to a
      dictionary.  If it so happens that <code>ensemblePtr->subcommandList</code> and
      <code>ensemblePtr->subcommandDict</code> are the same Tcl_Obj, the
      storage for the List internal representation is deallocated.
      
      A similar issue is [1670091].
      
    5. foundin initialized to: "trunk"
    6. is_private initialized to: "0"
    7. login: "pooryorick"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "e476148cded301ffff84bcdc432536dc0c949e88"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "pooryorick"
    14. subsystem initialized to: "21. [namespace]"
    15. title initialized to:
      ensemble: segmentation fault when  -subcommand and -map values are the same object
      
    16. type initialized to: "Bug"
  2. Ticket change [2362961bbc] (rid 158921) by pooryorick on 2017-11-25 16:41:36:

    1. closedate changed to: "2458083.19556701"
    2. closer changed to: "pooryorick"
    3. icomment: "Fixed in commit [046a5af026]."
    4. login: "pooryorick"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
  3. Ticket change [9ca873754f] (rid 158969) by dgp on 2017-11-28 18:19:27:

    1. closedate changed to: "2458086.26351532"
    2. closer changed to: "dgp"
    3. icomment:
      
      Is there a reason TclListCopy() did not figure in the solution here?
      
    4. login: "dgp"
    5. mimetype: "text/plain"
  4. Ticket change [8a3aeaf7d8] (rid 158970) by dgp on 2017-11-28 18:19:52:

    1. closedate changed to: "2458086.26379911"
    2. icomment: "er, TclListObjCopy()"
    3. login: "dgp"
    4. mimetype: "text/plain"
  5. Ticket change [744572fd67] (rid 158972) by sebres on 2017-11-28 21:28:23:

    1. closer changed to: "nobody"
    2. foundin changed to: ">= 8.5"
    3. icomment:
      > Is there a reason TclListCopy() did not figure in the solution here?
      
      In my opinion this is anyway too hard to duplicate a list/dict in such obscure case (normally it would be enough to use construct as below to say it is in the dict instead of search in the dict):
      ```
      if (!(i & 1) && i < subcmdc-1) {
          target = subcmdv[i+1];
      } else {
          target = NULL;
      }
      ```
      But unfortunately there is another obscure case (map used quasi as filtering):
      ```
      proc ::two {} {return 2}
      proc ::three {} {return 3}
      set list {one ::two one ::three}
      namespace ensemble configure n -subcommands $lst -map $lst
      
      % n one
      3
      ```
      
      But I've another own branch where ensembles map/list handling rewritten, and this case with duplication is fixed there. I'll try to rebase it here.
      
      Additionally I reopen this because currently all versions (supported ensembles) are affected.
      ATM fixed for core-8-branch only, I'll provide new one for 8.5 and if accepted reintegrate it for all versions (8.5 and higher).
      The test case is cherry-picked as is.
      
    4. login: "sebres"
    5. mimetype: "text/plain"
    6. status changed to: "Open"
  6. Ticket change [806a80e891] (rid 159047) by sebres on 2017-11-29 14:18:35:

    1. icomment:
      Fixed in [f9e184a041] for 8.5 without duplication, +1 additional test-case to cover the last wins case (on dict's like {one ::two one ::three}, where "one" should be mapped to "::three").
      
      And small code review to make the things simpler.
      
      If it is accepted I'll reintegrate it into 8.6 and higher (consider the move from tclNamesp.c to tclEnsemble.c).
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
    4. status changed to: "Pending"
  7. Ticket change [8208078e07] (rid 159159) by dgp on 2017-11-30 18:18:57:

    1. icomment:
      
      I prefer the fix in [d3ba3a9f51] . It directly addresses the need to protect the pointer returned by Tcl_ListObjGetElements() and thus directly solves the problem instead of handling one particular set of circumstances known to cause the problem.  And it's smaller.
      
      It does create and destroy one additional Tcl_Obj, but that's been engineered to be efficient already, and TclListObjCopy() only pays a large copying cost when it needs to, which is almost never, only for bug conditions like this.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  8. Ticket change [7f4f92e7ab] (rid 159160) by sebres on 2017-11-30 18:57:19:

    1. icomment:
      > It does create and destroy one additional Tcl_Obj...
      
      And converts dict to the list (and of course copy this list), then back to the dict, and then again to the list...
      
      > And it's smaller.
      
      Yes, the change as is 2-3 lines shorter... But are we in the save the lines mode now?
      
    2. login: "sebres"
    3. mimetype: "text/plain"
  9. Ticket change [41fbd745dc] (rid 159244) by pooryorick on 2017-12-04 10:18:42:

    1. icomment:
      I like sebres' fix because I like the idea of avoiding that additional type conversion, and I like the code as "documentation" of a real corner the case where the same value has explicitly been put to use as both a list and a dictionary.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [79960313cc] (rid 159252) by dgp on 2017-12-04 18:37:42:

    1. icomment:
      
      See what you think of the new fix.
      
      https://core.tcl.tk/tcl/info/f8daa294c6a88076
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  11. Ticket change [72c25ef87b] (rid 159253) by sebres on 2017-12-04 21:14:07:

    1. icomment:
      I like the idea basically, but you've made a large performance regression on creating of each ensemble ("normal" case as well as "strange" case)...
      
      For example in "normal" case (where map != list) by N sub-commands for ensemble:
      Previously (original):<pre>
        - iterate over LIST for N elements;
          - search in target hash-table (also N times).
          - search for replacement in DICT (also N times);
          - set value in target hash-table;
      </pre>
      New ([f8daa294c6a88076]):<pre>
        - iterate over DICT for N elements;
          - iterate over LIST for N elements (N*N times);
            - search/create in target hash-table (also N*N times).
            - set value in target hash-table;
        - iterate over LIST for N elements (the second "if");
          - search in target hash-table (also N times).
      </pre>
      
      E. g. by 100 sub-commands you've almost 10x overhead there:<pre>
      -  23.508 µs/# 39808 # 42538.6 #/sec 935.809 nett-ms
      + 268.819 µs/#  3698 #  3720.0 #/sec 994.092 nett-ms
      </pre>
      Therefore I don't think it would be better now...
      
      What exactly don't like you in my solution [f9e184a041]?
      Possibly goto's?
      
    2. login: "sebres"
    3. mimetype: "text/x-fossil-wiki"
  12. Ticket change [2ee78c0cc2] (rid 159258) by dgp on 2017-12-05 14:45:11:

    1. icomment:
      
      I made another re-working and got a lot closer to what sebres contributed.
      
      I think we're close enough to agreement now to merge the fix forward.  If we need more changes we can always make them.
      
      Thanks!
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  13. Ticket change [8c87e539c2] (rid 159259) by dgp on 2017-12-05 14:45:27:

    1. icomment:
      
      I made another re-working and got a lot closer to what sebres contributed.
      
      I think we're close enough to agreement now to merge the fix forward.  If we need more changes we can always make them.
      
      Thanks!
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  14. Ticket change [1435481618] (rid 159274) by dgp on 2017-12-05 17:25:20:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2458093.22592804"
    3. closer changed to: "dgp"
    4. icomment:
      
      Fix merged forward.  In reflection would have been better to fix only 8.6+.
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. status changed to: "Closed"