Skip to content
Tcl Source Code History Of Ticket 3084489
Login

History Of Ticket 3084489

Artifacts Associated With Ticket 3084489

  1. Ticket change [b563407f82] (rid 125236) by anonymous on 2010-10-10 00:43:20:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      http://mkextensions.sourceforge.net/mkGeneric13.htm package provides C commands called lminus and linter.  Under Tcl 8.4 the commands work as expected.  Under Tcl 8.5.7 (running in AOLserver 4.5 on Windows, have not tested on any other platform), providing a pure tcl list (no string rep) as an argument to lminus will result in having the original list's list structure resorted.  (In the scenario in which I discovered this, I actually see the string rep retain the original sequence even as list commands return data in different sequence from its string rep but I don't have a simple test case for that side-effect).
      
      As far as I can tell by looking at the source for this command, the first thing it does is Tcl_DuplicateObj (arvg[1]) (it uses a _DOB macro) and then performs its sort operation on the resulting object.
      
      Here is Tcl code you can use to replicate this problem:
      set listA [list c b a]
      set listB [list c b a z]
      lminus $listB $listA
      lindex $listA 0
      - will return a instead of c
      
      Again lists must be pure. If you do set listA "c b a", the problem does not occur.
      
      Feel free to email to [email protected] with any questions
      
    4. foundin initialized to: "obsolete: 8.5.7"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. subsystem initialized to: "10. Objects"
    10. title initialized to:
      Serious issue: Tcl_DuplicateObj isn't making a copy?
      
    11. type initialized to: "Bug"
  2. Ticket change [783b8daec5] (rid 89924) by msofer on 2010-10-10 18:18:41:

    1. closedate changed to: "2010-10-10T11:18:41"
    2. closer changed to: "msofer"
    3. icomment:
      This is almost certainly a bug in mk stuff, not Tcl. Please report to that project, or provide evidence that it is a Tcl problem.
      
      I could not easily find the source for lminus, so can't tell for sure. But here's my guess: there is a call of TclListObjGetElements, and then a sort is done in place. This is NOT a valid usage. To quote the manual http://www.tcl.tk/man/tcl8.5/TclLib/ListObj.htm: "The memory pointed to is managed by Tcl and should not be freed or written to by the caller."
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Invalid"
    7. status changed to: "Pending"
    8. username: "msofer"
  3. Ticket change [f8f70f9b47] (rid 91628) by ferrieux on 2010-10-10 20:10:21:

    1. icomment:
      Indeed that's an mk bug, but we have to admit that the Tcl core does nasty tricks with lists. Indeed, the List internal repr has its own level of refcounting, and the dupProc of the List type uses this to do as little work as reasonable: it only shares the internal rep, upping the refcount ! A secondary consequence is that (!Tcl_IsShared) does not allow to modify in place; the deeper test on listRepPtr->refCount is needed...
      
      As a result, all functions that do copy-on-write on lists *must* use more explicit duplication at the deeper level of intreps, eg by calling NewListIntRep. None of this is discussed in ListObj." by the way :(
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [6f768d79d6] (rid 100324) by msofer on 2010-10-10 20:31:31:

    1. icomment:
      Internal workings of internal reps is ... indeed internal, not part of the api :P 
      
      You should not write to the intReps of any obj, except through the api. Or be prepared to update your code if/when internal workings change. 
      
      As to the "nasty things": this is done to avoid having to copy things over when you just want to get a list obj that is protected against shimmering, and do it cheaply (without copying).
      
      
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [539f614b6c] (rid 93791) by ferrieux on 2010-10-10 22:50:10:

    1. icomment:
      Oh you're right Miguel ! I was saying this from the core's POV, not the extension...
      Certainly didn't want to dent the OP's motivation to file a bug report to mk :)
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [393567d4e0] (rid 112349) by anonymous on 2010-10-11 22:34:16:

    1. icomment:
      
      
      File Added - 389611: mkGeneric13.c
      
      
      
    2. login: ""
    3. mimetype: "text/plain"
    4. username: ""
  7. Add attachment "mkGeneric13.c" [4c335d1c50] (rid 126839) by anonymous on 2010-10-11 22:34:16.

  8. Ticket change [cbc8116ff8] (rid 95583) by anonymous on 2010-10-11 22:40:54:

    1. icomment:
      See source I uploaded starting on line 1133.  The code doesn't make any calls to any private APIs and works fine in 8.4.  It first calls Tcl_DuplicateObj (_DOB) and only then Tcl_ListObjGetElements (_LOGE) and then qsort.
      
      
    2. login: ""
    3. mimetype: "text/plain"
    4. username: ""
  9. Ticket change [e3216df1aa] (rid 87740) by msofer on 2010-10-12 05:10:13:

    1. icomment:
      The problem is that the C-array returned by TLOGE is meant to be only for reading, and this app is WRITING to it (sorting the elements in place). Again, TLOGE's 8.5 man page is clear: "The memory pointed to is
      managed by Tcl and should not be freed or written to by the caller."
      
      The 8.4 man page refers only not freeing the mem, so this usage was not explicitly invalid in 8.4.
      
      The solution is to make your own copy: Tcl_NewListObj(...), then sort that in place.
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  10. Ticket change [3abf5e368e] (rid 112612) by sf-robot on 2010-10-24 18:20:03:

    1. closedate changed to: "2010-10-24T11:20:03"
    2. closer changed to: "sf-robot"
    3. icomment:
      This Tracker item was closed automatically by the system. It was
      previously set to a Pending status, and the original submitter
      did not respond within 14 days (the time period specified by
      the administrator of this Tracker).
      
      
    4. login: "sf-robot"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "sf-robot"