Skip to content
Tcl Source Code History Of Ticket 686782ffffffffff
Login

History Of Ticket 686782ffffffffff

Artifacts Associated With Ticket 686782ffffffffff

  1. Ticket change [fa1bd84ed0] (rid 91820) by rmax on 2003-02-14 21:09:40:

    1. assignee initialized to: "vincentdarley"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The following expect script shows unexpected (sic)
      behaviour when run on Tcl as of 2003/01/17 or later:
      
       spawn /bin/echo "test\nfoo\nbar\nbla"
       while 1 {
          expect {
              -re "\n" { lappend lines $expect_out(buffer) }
              eof break
          }
       }
       foreach line $lines { puts "»$line«" }
      
      It should print:
      ---------------
      »test
      «
      »foo
      «
      »bar
      «
      »bla
      «
      ---------------
      but it does print something like:
      ---------------
      »test
      «
      »foo
      b«
      »ar
      bl«
      ---------------
      
      On some machines it fails almost every time, on others
      only once in a while. If expect is being run on a i386
      under valgrind, the misbehaviour occurs every time. If
      Tcl_SetObjLength() get's reverted to r1.26 the problem
      disappears.
      
      
    4. foundin initialized to: "obsolete: 8.4.1.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "rmax"
    9. subsystem initialized to: "44. UTF-8 Strings"
    10. title initialized to: "Changes to Tcl_SetObjLength() break "expect -re""
    11. type initialized to: "Bug"
  2. Ticket change [90637e1776] (rid 120443) by hobbs on 2003-02-15 07:29:13:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      This appears to be a regression from 8.4.1 in trying to fix 
      tclStringObj.c issues.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    6. username: "hobbs"
  3. Ticket change [b65ac46f4c] (rid 125405) by vincentdarley on 2003-02-15 18:57:51:

    1. assignee changed to: "das"
    2. icomment:
      Logged In: YES 
      user_id=32170
      
      I imagine Daniel's patch fixes this problem?
      
      
      
    3. login: "vincentdarley"
    4. mimetype: "text/plain"
    5. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    6. username: "vincentdarley"
  4. Ticket change [d9b5063853] (rid 107651) by nobody on 2003-02-17 16:38:43:

    1. icomment:
      Logged In: NO 
      
      Where can I find that patch?
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  5. Ticket change [62124ce717] (rid 92354) by rmax on 2003-02-18 02:04:26:

    1. icomment:
      Logged In: YES 
      user_id=124643
      
      Further investigation has shown, that at a point where
      expect's match buffer starts growing rapidly, it's string
      and unicode rep get out of sync. This means, the string rep
      changes, but the unicode rep, that is used for regexp
      matching stays the same. I hve instrumented
      Tcl_RegExpExecObj() to show the difference:
      
          Tcl_DString ds;
      ...
          Tcl_DStringInit(&ds);
          Tcl_UniCharToUtfDString(udata, length, &ds);
          fprintf(stderr, ">> string: %s\n", Tcl_GetString(objPtr));
          fprintf(stderr, ">>unicode: %s\n", Tcl_DStringValue(&ds));
          Tcl_DStringFree(&ds);
      
      Normally the two strings printed should always be the same,
      but after some time, the unicode rep seems to "freeze" while
      the string rep keeps walking trough the input with an offset
      according to the first match withing the unicode rep. Here
      is an example of another test script (attached) at the point
      where it happens:
      
      --- here it is still ok ---
      >> string: abc
      defg
      >>unicode: abc
      defg
      
      --- and here it happens... ---
      >> string: defg
      hijkl
      >>unicode: abc
      defg
      
      From there on, the unicode rep will remain the same while
      the string rep keeps changing.
      
      I suppose, that either expect doesn't correctly invalidate
      the unicode rep when it changes the string rep, or that
      Tcl_SetObjLength() does something wrong with the
      representations under certain conditions that are triggered
      by expect.
      
      
      
    2. login: "rmax"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "rmax"
  6. Add attachment "test2" [c01e95e8ac] (rid 102352) by rmax on 2003-02-18 02:04:27.

  7. Ticket change [52c3f814e5] (rid 126372) by rmax on 2003-02-18 02:04:27:

    1. icomment:
      
      
      File Added - 42689: test2
      
      
      
    2. login: "rmax"
    3. mimetype: "text/plain"
    4. username: "rmax"
  8. Ticket change [f84868ad4f] (rid 91515) by rmax on 2003-02-18 04:34:23:

    1. icomment:
      Logged In: YES 
      user_id=124643
      
      I think I gou it:
      expect.c around line 2220 modifies the contents of the
      pointer that comes back from Tcl_GetStringFromObj():
      
      ---- snip ----
      str = Tcl_GetStringFromObj(esPtr->buffer, &length);
      ...
      if (length != 0) {
          memmove(str,str+match,length-match);
      }
      Tcl_SetObjLength(esPtr->buffer, length-match);
      --- snap ----
      
      This modifies the string rep, but doesn't update the unicode
      string.
      
      
    2. login: "rmax"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "rmax"
  9. Ticket change [ae32b4646e] (rid 101601) by vincentdarley on 2003-02-18 17:04:16:

    1. icomment:
      
      
      File Added - 42755: stringUtf.diff
      
      Logged In: YES 
      user_id=32170
      
      You've hit the nail on the head there.  objPtr->bytes 
      should be considered read-only.  What we need is a new 
      API which removes the unicode rep entirely.  There are 
      actually a few places in Tcl's core which do this too.
      
      I've attached a patch which fixes the core areas.  
      Daniel's patch should also be applied.  However, it 
      looks as if expect.c needs fixing too.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "vincentdarley"
  10. Add attachment "stringUtf.diff" [b7cc8bb213] (rid 128860) by vincentdarley on 2003-02-18 17:04:16.

  11. Ticket change [a489a92934] (rid 110224) by vincentdarley on 2003-02-18 17:16:14:

    1. icomment:
      
      
      File Added - 42758: tclStringObj1.diff
      
      Logged In: YES 
      user_id=32170
      
      Adding Daniel's patch.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. priority changed to: "9 Immediate"
    5. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    6. username: "vincentdarley"
  12. Add attachment "tclStringObj1.diff" [4ac0a4f38c] (rid 126581) by vincentdarley on 2003-02-18 17:16:14.

  13. Ticket change [9175b4e82b] (rid 120620) by dkf on 2003-02-18 17:16:28:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Removing the Unicode rep of an object is trivial.  Just nuke
      the internal rep (free it and set the type to NULL.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "dkf"
  14. Ticket change [60e22dfa94] (rid 92145) by rmax on 2003-02-18 17:26:26:

    1. icomment:
      Logged In: YES 
      user_id=124643
      
      There were several places in expect where it relied on the
      undocumented side effect of the old Tcl_SetObjLength() to
      remove the internal rep. For the time being I have added a
      expInvalidateInternalRep() function to our expect package
      that just calls the freeIntRepProc of the object type and
      then sets the typePtr to NULL, as suggested on yesterday's
      chat by Jeff and Kevin, and by dkf below, while I was typing
      these lines ;).
      
      But I imagine, that there are other extensions and
      applications which also rely on the old behaviour of
      Tcl_SetObjLength(). So it might be better to not change that
      before the next major release.
      
      Mabe Tcl_SetObjLength() could be split in two parts, a
      private one that keeps the internal rep and can be used by
      the core, and a public wrapper which maintains the current
      behaviour.
      
      
      
    2. login: "rmax"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "rmax"
  15. Ticket change [59f7b9c198] (rid 118058) by vincentdarley on 2003-02-18 17:33:18:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      You're right -- no new API needed.  The stringUtf.diff 
      can be used to isolate those core places (just 3 or 4) 
      where my analysis shows a freeing of internal rep is 
      required to avoid potential bugs/crashes.
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. priority changed to: "8"
    5. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    6. username: "vincentdarley"
  16. Ticket change [98f0e8a56a] (rid 110694) by vincentdarley on 2003-02-18 17:40:19:

    1. icomment:
      Logged In: YES 
      user_id=32170
      
      As far as whether we should make this change now, or 
      not, I say fix the problem now.  Expect should really not 
      be manipulating those bytes:
      
      "Tcl_GetStringFromObj and Tcl_GetString return an 
      object's string representation..(snip)...  The storage 
      referenced by the returned byte pointer is owned by the 
      object manager and should not be modified by the 
      caller."
      
      quote from the man pages...
      
      
      
    2. login: "vincentdarley"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "vincentdarley"
  17. Ticket change [2931ab8655] (rid 88832) by das on 2003-02-18 17:50:26:

    1. icomment:
      Logged In: YES 
      user_id=90580
      
      vince, thanks for attaching the patch, sorry for being slow.
      
      reinhardt, does this fix the problem you see? I don't have any 
      problem with my expect -re scripts anymore with this without 
      having to change expect. (the patch restores the 
      abovementioned Tcl_SetObjLength side effect)
      
      if yes, this should definitely be applied before 8.4.3
      
      for efficiency, we might want to consider new API in the future to 
      invalidate the unicode rep explicitly without freeing its associated 
      memory (to avoid deallocating and reallocating the unicode 
      buffer repeatedly, thus defeating the memory optimizations in 
      tclStringObj.c)
      
      I've proposed Tcl_InvalidateUnicode() or/and 
      Tcl_SetUnicodeLength() (where a length param of -1 would 
      invalidate the unicode rep)
      
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "das"
  18. Ticket change [c51305696f] (rid 111935) by rmax on 2003-02-18 18:35:15:

    1. icomment:
      Logged In: YES 
      user_id=124643
      
      Thanks, Daniel.
      
      Your patch fixes it without needing further changes to
      expect or the Tcl core. I think it should even still go into
      8.4.2.
      
      
    2. login: "rmax"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "rmax"
  19. Ticket change [5b3763e7f9] (rid 118280) by das on 2003-02-18 18:44:26:

    1. icomment:
      Logged In: YES 
      user_id=90580
      
      ack, of course 8.4.2 is what I meant, sorry...
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "das"
  20. Ticket change [f26c57c2ed] (rid 109534) by das on 2003-02-18 18:52:03:

    1. icomment:
      Logged In: YES 
      user_id=90580
      
      also c.f. bug 635200
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    5. username: "das"
  21. Ticket change [750a73e724] (rid 105326) by das on 2003-02-19 23:58:01:

    1. closedate changed to: "2003-02-19T16:58:01"
    2. closer changed to: "das"
    3. icomment:
      Logged In: YES 
      user_id=90580
      
      checked in attached tclStringObj.diff
      
      
    4. login: "das"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. title changed to: "Changes to Tcl_SetObjLength() break "expect -re""
    9. username: "das"