Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-18
21:41 • Ticket [218851ffff] Some bugs in the new Trf patch added to the core status ... artifact: 8fbbcc30ea user: dgp
2000-10-26
08:30 • Closed ticket [218851ffff]. artifact: aef85b4501 user: welch
01:06 • New ticket [218851ffff]. artifact: 4bdea56891 user: nobody

Some bugs in the new Trf patch added to the core

Closed / Fixed218851ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:06:38
OriginalBugID: 2386 Bug
Version: 8.2b1
SubmitDate: '1999-07-19'
LastModified: '1999-07-30'
Severity: CRIT
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Linux
OSVersion: 2.0.29
Machine: Other
FixedDate: '1999-07-30'
FixedInVersion: 8.2b2
ClosedDate: '2000-10-25'


Name:

Andreas Kupries



Extensions:

None



CustomShell:

See above.



ReproducibleScript:

Well, the Trf patch is now in the core, hurray. The downside

    is that while changing the patch to accomodate an additional

    constraint requested by Scriptics (do not invalidate existing

    references to a Tcl_Channel while stacking a transformation

    on it) I added in some new errors as well, some of which will

    crash the interpreter. Here is a patch fixing the lot I found

    so far.



ObservedBehavior:

Interpreter crash, panic because of empty input buffer queue,

    fileevent was not working anymore for stacked transforms. :-(



DesiredBehavior:

Well, nothing of the above.



Patch:

*** tclIO.cFri Jul  2 21:51:29 1999

--- ../../patch.trf/tclIO.c.8.2Wed Jul 14 21:53:52 1999

***************

*** 10,16 ****

   * See the file "license.terms" for information on usage and redistribution

   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.

   *

!  * RCS: @(#) $Id: tclIO.c,v 1.10 1999/07/02 19:51:29 welch Exp $

   */

  

  #include "tclInt.h"

--- 10,16 ----

   * See the file "license.terms" for information on usage and redistribution

   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.

   *

!  * RCS: @(#) $Id: tclIO.c,v 1.8 1999/05/18 20:17:59 hershey Exp $

   */

  

  #include "tclInt.h"

***************

*** 1391,1396 ****

--- 1391,1397 ----

  {

      ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

      Channel            *chanPtr, *pt;

+     int                 interest = 0;

  

      /*

       * AK, 06/30/1999

***************

*** 1449,1454 ****

--- 1450,1468 ----

      chanPtr = (Channel *) ckalloc((unsigned) sizeof(Channel));

  

      /*

+      * If there is some interest in the channel, remove it, break

+      * down the whole chain. It will be reconstructed later.

+      */

+ 

+     interest = pt->interestMask;

+ 

+     pt->interestMask = 0;

+ 

+     if (interest) {

+         (pt->typePtr->watchProc) (pt->instanceData, 0);

+     }

+ 

+     /*

       * Save some of the current state into the new structure,

       * reinitialize the parts which will stay with the transformation.

       *

***************

*** 1496,1502 ****

      chanPtr->outQueueHead        = pt->outQueueHead; /* Save */

      chanPtr->outQueueTail        = pt->outQueueTail; /* Save */

      chanPtr->saveInBufPtr        = pt->saveInBufPtr; /* Save */

!     chanPtr->inQueueHead         = pt->outQueueHead; /* Save */

      chanPtr->inQueueTail         = pt->inQueueTail;  /* Save */

  

      chanPtr->chPtr               = (ChannelHandler *) NULL;  /* TTO */

--- 1510,1516 ----

      chanPtr->outQueueHead        = pt->outQueueHead; /* Save */

      chanPtr->outQueueTail        = pt->outQueueTail; /* Save */

      chanPtr->saveInBufPtr        = pt->saveInBufPtr; /* Save */

!     chanPtr->inQueueHead         = pt->inQueueHead;  /* Save */

      chanPtr->inQueueTail         = pt->inQueueTail;  /* Save */

  

      chanPtr->chPtr               = (ChannelHandler *) NULL;  /* TTO */

***************

*** 1527,1535 ****

       * - The information about encoding and eol-translation is taken

       *   without change.  There is no need to fiddle with

       *   refCount et. al.

       */

  

!     pt->flags               = mask;

  

      /*

       * EDITORS NOTE:  all the lines with "take it as is" should get

--- 1541,1551 ----

       * - The information about encoding and eol-translation is taken

       *   without change.  There is no need to fiddle with

       *   refCount et. al.

+      *

+      * Don't forget to use the same blocking mode as the old channel.

       */

  

!     pt->flags               = mask | (chanPtr->flags & CHANNEL_NONBLOCKING);

  

      /*

       * EDITORS NOTE:  all the lines with "take it as is" should get

***************

*** 1598,1607 ****

       * between them.

       */

  

!     if (pt->interestMask) {

!         int interest = pt->interestMask;

! 

! pt->interestMask = 0;

          (pt->typePtr->watchProc) (pt->instanceData, interest);

      }

  

--- 1614,1620 ----

       * between them.

       */

  

!     if (interest) {

          (pt->typePtr->watchProc) (pt->instanceData, interest);

      }

  

***************

*** 1680,1689 ****

   * use correction code to ensure this.

   */

  

! memcpy ((void*) &top,         (void*) chanPtr,     sizeof (Channel));

! memcpy ((void*) &chanPtr,     (void*) chanDownPtr, sizeof (Channel));

  top.supercedes = (Channel*) NULL;

! memcpy ((void*) &chanDownPtr, (void*) &top,        sizeof (Channel));

  

  chanPtr->refCount        = chanDownPtr->refCount;

  chanPtr->closeCbPtr      = chanDownPtr->closeCbPtr;

--- 1693,1702 ----

   * use correction code to ensure this.

   */

  

! memcpy ((void*) &top,        (void*) chanPtr,     sizeof (Channel));

! memcpy ((void*) chanPtr,     (void*) chanDownPtr, sizeof (Channel));

  top.supercedes = (Channel*) NULL;

! memcpy ((void*) chanDownPtr, (void*) &top,        sizeof (Channel));

  

  chanPtr->refCount        = chanDownPtr->refCount;

  chanPtr->closeCbPtr      = chanDownPtr->closeCbPtr;

***************

*** 6085,6145 ****

      ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

      NextChannelHandler nh;

  

!     /*

!      * Preserve the channel struct in case the script closes it.

       */

       

!     Tcl_Preserve((ClientData) channel);

  

!     /*

!      * If we are flushing in the background, be sure to call FlushChannel

!      * for writable events.  Note that we have to discard the writable

!      * event so we don't call any write handlers before the flush is

!      * complete.

!      */

  

!     if ((chanPtr->flags & BG_FLUSH_SCHEDULED) && (mask & TCL_WRITABLE)) {

! FlushChannel(NULL, chanPtr, 1);

! mask &= ~TCL_WRITABLE;

!     }

  

!     /*

!      * Add this invocation to the list of recursive invocations of

!      * ChannelHandlerEventProc.

!      */

      

!     nh.nextHandlerPtr = (ChannelHandler *) NULL;

!     nh.nestedHandlerPtr = tsdPtr->nestedHandlerPtr;

!     tsdPtr->nestedHandlerPtr = &nh;

      

!     for (chPtr = chanPtr->chPtr; chPtr != (ChannelHandler *) NULL; ) {

  

!         /*

!          * If this channel handler is interested in any of the events that

!          * have occurred on the channel, invoke its procedure.

!          */

          

!         if ((chPtr->mask & mask) != 0) {

!             nh.nextHandlerPtr = chPtr->nextPtr;

!     (*(chPtr->proc))(chPtr->clientData, mask);

!             chPtr = nh.nextHandlerPtr;

!         } else {

!             chPtr = chPtr->nextPtr;

  }

-     }

  

!     /*

!      * Update the notifier interest, since it may have changed after

!      * invoking event handlers.

!      */

  

!     if (chanPtr->typePtr != NULL) {

! UpdateInterest(chanPtr);

!     }

  

!     Tcl_Release((ClientData) channel);

  

!     tsdPtr->nestedHandlerPtr = nh.nestedHandlerPtr;

  }

  

  /*

--- 6098,6174 ----

      ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);

      NextChannelHandler nh;

  

!     /* Walk all channels in a stack ! and notify them in order.

       */

+ 

+     while (chanPtr !=  (Channel *) NULL) {

+         /*

+  * Preserve the channel struct in case the script closes it.

+  */

       

!         Tcl_Preserve((ClientData) channel);

  

! /*

!  * If we are flushing in the background, be sure to call FlushChannel

!  * for writable events.  Note that we have to discard the writable

!  * event so we don't call any write handlers before the flush is

!  * complete.

!  */

  

! if ((chanPtr->flags & BG_FLUSH_SCHEDULED) && (mask & TCL_WRITABLE)) {

!     FlushChannel(NULL, chanPtr, 1);

!     mask &= ~TCL_WRITABLE;

! }

  

! /*

!  * Add this invocation to the list of recursive invocations of

!  * ChannelHandlerEventProc.

!  */

      

! nh.nextHandlerPtr = (ChannelHandler *) NULL;

! nh.nestedHandlerPtr = tsdPtr->nestedHandlerPtr;

! tsdPtr->nestedHandlerPtr = &nh;

      

! for (chPtr = chanPtr->chPtr; chPtr != (ChannelHandler *) NULL; ) {

  

!     /*

!      * If this channel handler is interested in any of the events that

!      * have occurred on the channel, invoke its procedure.

!      */

          

!   if ((chPtr->mask & mask) != 0) {

!               nh.nextHandlerPtr = chPtr->nextPtr;

!       (*(chPtr->proc))(chPtr->clientData, mask);

!       chPtr = nh.nextHandlerPtr;

!   } else {

!               chPtr = chPtr->nextPtr;

!   }

  }

  

! /*

!  * Update the notifier interest, since it may have changed after

!  * invoking event handlers. Skip that if the channel was deleted

!  * in the call to the channel handler.

!  */

  

! if (chanPtr->typePtr != NULL) {

!     UpdateInterest(chanPtr);

  

!     /* Walk down the stack.

!      */

!   chanPtr = chanPtr-> supercedes;

! } else {

!     /* Stop walking the chain, the whole stack was destroyed!

!      */

!     chanPtr = (Channel*) NULL;

! }

! 

! Tcl_Release((ClientData) channel);

! 

! tsdPtr->nestedHandlerPtr = nh.nestedHandlerPtr;

  

! channel = (Tcl_Channel) chanPtr;

!     }

  }

  

  /*

***************

*** 8128,8131 ****

--- 8157,8161 ----

      }

      return TCL_OK;

  }

+



PatchFiles:

tclIO.c
welch Closed ticket [218851ffff]. [History diff]2000-10-26 08:30:14
dgp Ticket [218851ffff]: 3 changes [History diff]2001-04-18 21:41:43
Log in (anonymous is fine) to add a comment.