Skip to content
Tcl Source Code History Of Ticket 219354ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 219354ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 219354ffffffffffffffffffffffffffffffffff

  1. Ticket change [404a2af740] (rid 121605) by nobody on 2000-10-26 05:11:15:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 5817 Bug
      Version: 8.2.3
      SubmitDate: '2000-06-06'
      LastModified: '2000-10-25'
      Severity: CRIT
      Status: UnAssn
      Submitter: techsupp
      OS: Solaris
      OSVersion: SunOS cs1.nyc.office.juno.com 5.6 Generic_105181-16 sun4u sparc
      Machine: SunOS cs1.nyc.office.juno.com 5.6 Generic_105181-16 sun4u sparc
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      
      Benjamin Vitale
      
      
      Extensions:
      
      TclX 8.2
      
      
      CustomShell:
      
      none, except the patch submitted above.
      
      
      Comments:
      
      I thought I had submitted another patch, but I don't see it here.
      
          anyway, it was incomplete- the select masks need to be reset
      
          in the EINTR case, otherwise ALL event handlers will fire, which is
      
          wrong.
      
      
      ReproducibleScript:
      
      1. run the following script.  tail -f sig.log; send a HUP signal. 
      
      
      2. telnet localhost 12346
      
      
      #!./tclsh
      
      
      package require Tclx
      
      
      signal trap HUP hup
      
      
      proc hup {} {
      
          log "hupping"
      
      }
      
      
      set s [socket -server accept 12346]
      
      
      proc reader {fd} {
      
          gets $fd line
      
          puts $fd "you said $line"
      
          flush $fd
      
      }
      
      
      proc accept {fd addr port} {
      
          log "accepting"
      
          puts $fd hello
      
          flush $fd
      
          fileevent $fd read "reader $fd"
      
      }
      
      
      close stdin
      
      close stdout
      
      # close stderr
      
      
      set logfd [open sig.log {CREAT APPEND WRONLY}]
      
      
      proc log {s} {
      
          global logfd
      
      
          puts $logfd "[clock format [clock seconds] -format "%H:%M:%S"] $s"
      
          flush $logfd
      
      }
      
      
      log hello
      
      
      proc bgerror {s} {
      
          log $s
      
      }
      
      
      vwait forever
      
      
      ObservedBehavior:
      
      the string 'hupping' does not appear in the log until you telnet
      
      
      DesiredBehavior:
      
      the string 'hupping' should appear in the log as soon as you send the HUP signal, even if no socket activity is occurring.
      
      
      Patch:
      
      ===================================================================
      
      RCS file: /proj/juno/repository/tcl/core/tcl/unix/tclUnixNotfy.c,v
      
      retrieving revision 1.1.1.2
      
      retrieving revision 1.3
      
      diff -u -r1.1.1.2 -r1.3
      
      --- tclUnixNotfy.c      2000/01/26 19:14:13     1.1.1.2
      
      +++ tclUnixNotfy.c      2000/06/02 06:25:31     1.3
      
      @@ -897,6 +897,8 @@
      
            */
      
      
           while (1) {
      
      +      int async_ready = 0;
      
      +
      
              /*
      
               * Set up the select mask to include the receive pipe.
      
               */
      
      @@ -941,6 +943,12 @@
      
                   * Try again immediately on an error.
      
                   */
      
      
      +         if (errno == EINTR && Tcl_AsyncReady ())
      
      +           {
      
      +             async_ready = 1;
      
      +             memset ((void *) &masks [0], 0, 3 * MASK_SIZE * sizeof (fd_mask));
      
      +           }
      
      +         else
      
                  continue;
      
               }
      
      
      @@ -957,7 +965,8 @@
      
                       found |= word;
      
                       (((long*)(tsdPtr->readyMasks))[i]) = word;
      
                  }
      
      -            if (found || (tsdPtr->pollState & POLL_DONE)) {
      
      +            if (found || (tsdPtr->pollState & POLL_DONE) || async_ready) {
      
      +               async_ready = 0;
      
                       tsdPtr->eventReady = 1;
      
                      Tcl_ConditionNotify(&tsdPtr->waitCV);
      
                      if (tsdPtr->onList) {
      
      
      PatchFiles:
      
      tclUnixNotfy.c
      
      
      
      
      
      
    4. foundin initialized to: "final: 8.2.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "threaded notifier does not work with signals"
    11. type initialized to: "Bug"
  2. Ticket change [3ad917693e] (rid 112629) by dkf on 2000-11-19 18:31:17:

    1. subsystem changed to: "95. contrib ports"
  3. Ticket change [28fc81a00c] (rid 88795) by dkf on 2001-02-08 21:47:55:

    1. subsystem changed to: "01. Notifier"
  4. Ticket change [4949092908] (rid 100033) by dkf on 2001-09-20 02:57:53:

    1. assignee changed to: "kennykb"
  5. Ticket change [f048a6967a] (rid 109164) by andreas_kupries on 2001-09-20 03:07:50:

    1. icomment:
      Logged In: YES 
      user_id=75003
      
      Benjamin Vitale = <[email protected]>.
      
      Also note that David Gravereaux did several changes 
      relating to Async handling for threaded tcl. This might 
      affect the bug and/or patch in this item.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  6. Ticket change [c57fec2188] (rid 112011) by hobbs on 2001-10-18 03:56:57:

    1. icomment:
      Logged In: YES 
      user_id=72656
      
      This may be already handled by closed bug 219251 by 
      davygrvy.
      
      
    2. login: "hobbs"
    3. mimetype: "text/plain"
    4. username: "hobbs"
  7. Ticket change [342b83216b] (rid 106712) by dkf on 2007-02-19 05:29:27:

    1. icomment:
      Logged In: YES 
      user_id=79902
      Originator: NO
      
      AIUI, getting threaded signal handling right is required for getting a merged mainline threaded Expect, which would let us move Tcl-on-Unix to being threaded by default. Raising prio.
      
      (It's alleged that jenglish knows something about threads-and-signals issues. I know I don't.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. priority changed to: "7 High"
    5. username: "dkf"
  8. Ticket change [f080ce9c96] (rid 109205) by dkf on 2009-06-18 15:37:58:

    1. priority changed to: "8"
    2. resolution changed to: "Remind"
  9. Ticket change [2a79d9dc96] (rid 118582) by das on 2009-06-29 23:54:24:

    1. closedate changed to: "2009-06-29T16:54:24"
    2. closer changed to: "das"
    3. icomment:
      
      
      allow_comments - 1
      
      AFAICT this can be closed as out of date, Tcl_AsyncMark() handles waking up the correct thread nowadays.
      
      Specifically, TclX_SignalInit() calls Tcl_AsyncCreate(ProcessSignals, NULL) for the first interp it is loaded in and installs a signal handler that calls Tcl_AsyncMark() on that async handler.
      In threaded tcl, Tcl_AsyncMark() calls Tcl_ThreadAlert() which calls Tcl_AlertNotifier() which wakes up the thread that called Tcl_AsyncCreate(), so the notifier thread no longer needs to do anything to ensure the async handler is called when a signal is received.
      
      
    4. login: "das"
    5. mimetype: "text/plain"
    6. resolution changed to: "Out of Date"
    7. status changed to: "Closed"
    8. username: "das"
  10. Ticket change [ebf19cd3db] (rid 103623) by das on 2009-06-30 00:43:25:

    1. icomment:
      one thing that should be noted however is that the signal handler implementation in TclX appears not to be async-signal safe in the threaded-tcl case, in particular the implementation of Tcl_AsyncMark() internally calls the non async-safe pthread_mutex_lock() multiple times as well as pthread_cond_broadcast().
      The Tcl docs make no guarantees that Tcl_AsyncMark() can safely be called from a signal handler (nor should they IMO).
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. username: "das"
  11. Ticket change [9964968a33] (rid 110786) by das on 2009-06-30 00:49:38:

    1. icomment:
      To be specific, Async.3 says
      When an asynchronous event  occurs  the  code that  detects  the  event (such as a signal handler) should call Tcl_AsyncMark with the token for the handler. 
      
      I don't know if that is meant to indicate that Tcl_AsyncMark() is intended to be async-signal safe, if yes, that is currently not the case in threaded tcl...
      
      
    2. login: "das"
    3. mimetype: "text/plain"
    4. username: "das"