Skip to content
Tcl Source Code History Of Ticket 39680865953cce4f
Login

History Of Ticket 39680865953cce4f

Artifacts Associated With Ticket 39680865953cce4f

  1. Ticket change [813777d4df] (rid 230020) by pooryorick on 2024-08-13 11:27:35:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      The following script should progressively report that it is writing to the
      channel, and eventually complete.  Instead it hangs after the first write to
      the channel:
      
      <code><verbatim>
      #! /usr/bin/env tclsh
      
      namespace eval rc {
      	namespace export *
      	namespace ensemble create
      
      	proc initialize {chan mode} {
      		namespace eval chan_$chan {
      			variable buffer {}
      			variable watch {}
      			variable writetask {}
      		}
      		return {initialize finalize watch write}
      	}
      
      
      	proc finalize chan {
      		namespace delete chan_$chan
      	}
      
      
      	proc watch {chan spec} {
      		namespace upvar chan_$chan watch watch writetask writetask
      		set watch $spec
      		after cancel $writetask
      		if {{write} in $spec} {
      			set writetask [after 0 [list after idle [list ::chan postevent $chan write]]]
      		}
      		return
      	}
      
      
      	proc write {chan data} {
      		namespace upvar chan_$chan buffer buffer watch watch \
      			writetask writetask
      		append buffer $data
      		after cancel writetask
      		if {{write} in $watch} {
      			set writetask [after 0 [
      				list after idle [list ::chan postevent $chan write]]]
      		}
      		return [string length $data]
      	}
      }
      
      set chan [chan create write [namespace which rc]]
      chan configure $chan -blocking 0
      coroutine c1 apply [list chan {
      	after 0 [list [info coroutine]] 
      	yield
      	chan event $chan writable [list [info coroutine]]
      	while {[incr i] < 1000000}  {
      		yield
      		puts [list writing to $chan $i]
      		puts $chan $i
      	}
      	set [namespace current]::done 1
      } [namespace current]] $chan
      vwait [namespace current]::done
      </verbatim></code>
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. private_contact initialized to: "ace48c675e6d9823c38a3aa91ffddc0ff84cc79f"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "pooryorick"
    13. subsystem initialized to: "- New Builtin Commands"
    14. title initialized to: "Basic nonblocking write-only refchan hangs"
    15. type initialized to: "Bug"
  2. Ticket change [08f15f7f32] (rid 230035) by pooryorick on 2024-08-13 13:47:40:

    1. icomment: "Fixed in [ab87ef464e12c190]."
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Pending"
  3. Ticket change [adef465221] (rid 230058) by jan.nijtmans on 2024-08-13 14:03:32:

    1. icomment:
      Moved to bug-3968086595 branch, so it can be properly reviewed (by a TCT member), before being merged to "trunk" and "core-8-branch".
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [554efca484] (rid 230059) by pooryorick on 2024-08-13 14:18:13:

    1. icomment:
      When was it decided that TCT members review each change?  That was never the case before.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [6d3ed0bf04] (rid 230060) by jan.nijtmans on 2024-08-13 14:55:22:

    1. icomment: "@ashok, @sergey, your comments please?"
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [cd8d19b5e0] (rid 230061) by jan.nijtmans on 2024-08-13 15:25:55:

    1. icomment:
      What "Version"? Do 8.6 (and 8.7) have the same problem too?
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [676054efed] (rid 230062) by apnadkarni on 2024-08-13 15:35:13:

    1. icomment:
      I only had a quick look as there are other higher priorities. At first glance, this is on the same lines as the proposed "fix" in earlier tickets that was reverted and my original objections to a polling model pretending to be event-driven are still likely to stand pending a closer look. Also, given the earlier "bug" reports that I still deem to be user programming errors, the test case in the report also needs to be reviewed for correctness. Again, something I can't spend time on until 9.0 release.
      
      Given where 9.0 is in the release cycle, even **if** this was a genuine bug, it is not important enough to look into for 9.0 relative to other issues so my opinion is to punt even investigating it till 9.0.1.
      
      @pooryorick, regarding "since when every change needs TCT review", I don't think that is being done. It so happens your change is essentially the same, or very close to, your earlier commits that were reverted for reasons discussed ad nauseum. When it was collectively agreed amongst 7-8 folks (with you being the *sole* exception) to revert those changes, it was only right of Jan to put them on a branch pending a review, whenever that might be.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  8. Ticket change [29a0113491] (rid 230063) by apnadkarni on 2024-08-13 15:39:42:

    1. icomment:
      Just so we do not go back and forth on this, I am not going to argue whether this is a bug or the fix is appropriate if so, and so on. I'm simply stating my opinion that this is to be revisited post 9.0 release. Also marking the bug open accordingly so it does not get lost.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
    4. resolution changed to: "None"
    5. status changed to: "Open"
  9. Ticket change [b3e44909b7] (rid 230064) by pooryorick on 2024-08-13 15:50:38:

    1. icomment:
      This fix is not the same as those that were previously argued, and the example that demonstrates the issue is also not the same.  The previous arguments were about 1) whether an asynchronous channel should immediately signal writable when a channel is opened, and 2) whether postevent is asynchronous.  This demo does not intersect with those concerns, and this fix touches on neither of those issues.  It only resolves the issue reported in this ticket.  If someone doesn't raise a specific objection to this particular fix, it should be merged into trunk.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [494db707f5] (rid 230065) by pooryorick on 2024-08-13 15:51:41:

    1. icomment:
      The core team should take care not to become a bottleneck to needed contributions.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  11. Ticket change [a08237b583] (rid 230066) by jan.nijtmans on 2024-08-13 16:29:49:

    1. icomment:
      In my judgement, the risk putting this into 9.0 is higher than the benefit. I'll bring this up next TTT meeting, I will report the decision here.
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  12. Ticket change [880be1cd5b] (rid 230068) by pooryorick on 2024-08-13 17:47:50:

    1. icomment:
      Jan, can you provide some details on what you think the risk is?
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  13. Ticket change [78ee3360cc] (rid 230080) by jan.nijtmans on 2024-08-14 07:52:59:

    1. icomment:
      You are right, it's not a "risk", it's an actual failure:
      
      [https://github.com/tcltk/tcl/actions/runs/10383146736/job/28747514350]
      <pre>
      chanio.test
      Test file error: child killed: segmentation violation
      ...
      io.test
      Test file error: child killed: segmentation violation
      </pre>
      
      (I took the freedom to start a CI build of your branch)
      
      For all other questions you might want to ask, you can find the answer [https://core.tcl-lang.org/tcl/wiki?name=Rationale+for+rollback+of+refchan+event+generation+in+core|here]
      (there are some additions by Andreas Kupries at the end of this document)
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  14. Ticket change [7541238afe] (rid 230082) by apnadkarni on 2024-08-14 10:50:26:

    1. icomment:
      Nathan, a working version of your channel implementation is below but first...
      
      *Nathan wrote: This fix is not the same as those that were previously argued, and the example that demonstrates the issue is also not the same. The previous arguments were about 1) whether an asynchronous channel should immediately signal writable when a channel is opened, and 2) whether postevent is asynchronous.*
      
      Not so. While 2) was a matter of requiring a TIP for incompatible changes to a public API where it could be discussed, 1) was only a symptom of a larger issue - continuous generation of "write" events without knowledge of actual channel state, something which completely defeats the purpose of event-based I/O turning it into a disguised polling model. The commit under discussion raises the same fears pending a thorough review, leave aside the question of whether those changes are even needed.
      
      *Nathan wrote: The core team should take care not to become a bottleneck to needed contributions.*
      
      While there will be some delay, I am afraid the time wasted this year chasing down and reverting or fixing commits that made it in without review is an order of magnitude higher.
      
      Getting to your sample script, below is a working version of a functionally similar refchan. The implementation is based on Aku's original paper. Note the refchan *implementation* may differ but I believe the *functionality* and *user* test code is the same as your refchan. Feel free to check that but my guess is that your refchan implementation has a bug or is incomplete as is the case in the two tickets you insist on reopening.
      
      ```
      namespace eval rc {
          namespace ensemble create
          namespace export *
          # Change to taste depending on how much CPU you want to hog
          variable delay 0
      
          proc finalize {chan args} {
              namespace upvar c_$chan timer timer buffer buffer
              catch {after cancel $timer}
              puts "Finalize: Have [string length $buffer] bytes."
              namespace delete c_$chan
          }
      
          proc initialize {chan args} {
              namespace eval c_$chan {}
              namespace upvar c_$chan watching watching timer timer buffer buffer
              set watching {}
              set buffer {}
              return {finalize initialize watch write}
          }
      
          proc watch {chan spec} {
              namespace upvar c_$chan watching watching
              set watching $spec
              update $chan
          }
      
          proc write {chan data} {
              namespace upvar c_$chan buffer buffer
              append buffer $data
              return [string length $data]
          }
      
          proc update {chan} {
              namespace upvar c_$chan watching watching timer timer
              variable delay
              catch {after cancel $timer}
              if {"write" in $watching} {
                  set timer [after idle after $delay \
                                 [namespace code [list post $chan]]]
              }
          }
      
          proc post {chan} {
              variable delay
              namespace upvar c_$chan watching watching timer timer
              if {"write" in $watching} {
                  set timer [after idle after $delay \
                                 [namespace code [list post $chan]]]
                  chan postevent $chan write
              }
          }
      }
      
      set chan [chan create write [namespace which rc]]
      chan configure $chan -blocking 0
      coroutine c1 apply [list chan {
          after 0 [list [info coroutine]]
          yield
          chan event $chan writable [list [info coroutine]]
          while {[incr i] < 1000000}  {
              yield
              puts [list writing to $chan $i]
              puts $chan $i
          }
          set [namespace current]::done 1
      } [namespace current]] $chan
      vwait [namespace current]::done
      close $chan
      ```
      
      For explanation of above, please see Aku's paper.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  15. Ticket change [b04022b2fc] (rid 230084) by pooryorick on 2024-08-14 11:14:40:

    1. icomment:
      Ashok, the "working" version of the implementation that you just proposed is exactly the strategy you are advocating against:  Continuous event posting on a timer that just keeps rescheduling itself.  In contrast, the fix that I produced at the C level does not do this.  Instead, it just takes care to propagate the signal that is sent from the refchan by not letting it get swallowed just because an internal buffer got in the way.  The issue that is illustrated in this ticket is that the C implementation currently swallows that signal.  It's entirely possible to fix this at the C level so that postevent signals sent by a refchan do not get swallowed.
      
      I could also complain about "orders of magnitude" of time that I've spent over the years correcting missteps that have been made in Tcl (ahem, the alphabet for strings for Tcl 9, or the numerous bugs that I make sure to diagnose and fix before even reporting them so that others don't have to wast their time on them), but I'm not going to engage in such bellyaching.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  16. Ticket change [ca7b689d1e] (rid 230085) by pooryorick on 2024-08-14 11:18:25:

    1. icomment:
      To summarize:  Implementing a continuously-self-scheduling timer at the script level is a bad hack to overcome a bad implementation.  This should be fixed.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  17. Ticket change [91081cf2ba] (rid 230086) by apnadkarni on 2024-08-14 11:32:47:

    1. icomment:
      Nope. See the delay at the top which allows control of how often the event is scheduled. It's 0 because your code had it as 0. In general, if a channel is capable of continuously sinking data, it is up to the channel to decide how often to generate events. In your original C implementation, it was continuously generating events (a) IRRESPECTIVE of channel state without giving the refchan control of (b) whether it needed to or not and (c) without giving a chance for idle handlers to run (the last of which you *may* have fixed).
      
      Now, perhaps your latest code is doing something in addition. I dunno. As I said, I don't have time to review for 9.0, and think it is risky at this stage to include without a review. The crashes in CI are proof as to why, whether you fix them or not. If someone else can review and finds it worthy, fine. Else 9.0.1.
      
      And your mention of the time you have spent correcting missteps is exactly why significant changes need to be reviewed before commits!
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  18. Ticket change [2b825d680b] (rid 230087) by apnadkarni on 2024-08-14 11:39:38:

    1. icomment:
      *Nathan wrote:  Implementing a continuously-self-scheduling timer at the script level is a bad hack to overcome a bad implementation. This should be fixed.*
      
      By all means, TIP and implement improvements.
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"
  19. Ticket change [8b3f2f63cd] (rid 230105) by pooryorick on 2024-08-15 11:08:58:

    1. icomment:
      This fix isn't about anything which would require a TIP.  It's only about making sure an event posted by a refchan doesn't get swallowed.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  20. Ticket change [b48fddb291] (rid 235014) by jan.nijtmans on 2024-11-12 20:21:05:

    1. closedate changed to: "2460627.34798541"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Since the TCT, in the online meeting from 11-11-2024, decided to close all tickets related to [https://core.tcl-lang.org/tcl/wiki?name=Rationale+for+rollback+of+refchan+event+generation+in+core|this] Technical Noted, and also decided to no longer allow relicensed code in Tcl official repositories (See: [560b27abdac4abe3]), this ticket can be closed.
      
      Thanks, Ashok, for providing a working versions of Nathan's non-working version, and pointing out the reason.
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Invalid"
    7. status changed to: "Closed"
  21. Ticket change [2fd6bb79d8] (rid 235109) by pooryorick on 2024-11-14 21:00:48:

    1. closedate changed to: "2460629.37555565"
    2. closer changed to: "pooryorick"
    3. icomment:
      This ticket is separate from that techinical note, and illustrates a real reproducible problem.  Therefore it should remain open until fixed.
      
    4. login: "pooryorick"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Accepted"