Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-08-19
14:03 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: 49ddc26fa0 user: pooryorick
2024-08-18
20:24 • Ticket [18f4a94d03]: 5 changes artifact: 280aabd0f7 user: jan.nijtmans
20:07 • Ticket [18f4a94d03]: 6 changes artifact: d61c2ccfb0 user: pooryorick
2024-08-13
19:26 • Ticket [18f4a94d03]: 6 changes artifact: f683832177 user: jan.nijtmans
2024-05-29
09:44
Fix [18f4a94d03], by reverting [9bcec7cd880540c3], which caused it. See [https://core.tcl-lang.org/t... check-in: 8d4d978bd3 user: jan.nijtmans tags: core-8-branch
2024-04-18
15:32
Fix [18f4a94d03] by backing out [9bcec7cd880540c3] (again) check-in: a2633b5cc5 user: jan.nijtmans tags: bug-18f4a94d03
15:04 • Ticket [080f846fd5] Channel system generating writable events BEFORE channel is ... artifact: 85049380dd user: jan.nijtmans
2021-06-19
21:53 • Closed ticket [18f4a94d03]: 8.7 : a blocking memory channel no longer works.</i... artifact: 9bae2779a6 user: pooryorick
2021-06-16
12:13 • Ticket [18f4a94d03]: 3 changes artifact: 1921f3537b user: pooryorick
12:11 • Ticket [18f4a94d03]: 3 changes artifact: f8314f905b user: pooryorick
12:07 • Add attachment memsock_vwait.test to ticket [18f4a94d03b075c6|18f4a94d0... artifact: 88476b4c3e user: pooryorick
11:26 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: c61274abe3 user: pooryorick
10:50 • Ticket [18f4a94d03]: 3 changes artifact: 1961f953a9 user: jan.nijtmans
10:34 • Ticket [18f4a94d03]: 3 changes artifact: 3ea0412c80 user: pooryorick
10:30 • Open ticket [18f4a94d03]. artifact: b9c8e0111c user: pooryorick
2021-06-15
15:02 • Closed ticket [18f4a94d03]. artifact: ff23819d4c user: jan.nijtmans
14:58 • Pending ticket [67a5eabbd3]: refchan, coroutine, and postevent from the "wa... artifact: f2c6446ced user: jan.nijtmans
14:55 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: d2820fb10f user: jan.nijtmans
14:54
Fix [18f4a94d03] by backing out [9bcec7cd880540c3] check-in: a785b5bf5e user: jan.nijtmans tags: core-8-branch
14:52
Fix [18f4a94d03] by backing out [9bcec7cd880540c3] closed check-in: ee3930e93a user: jan.nijtmans tags: bug-18f4a94d03
13:00 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: 546e9a354e user: jan.nijtmans
12:56
Fix [18f4a94d03] by backout out [9bcec7cd880540c3] check-in: 3f466e55c8 user: jan.nijtmans tags: bug-18f4a94d03
12:46 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: c3d29a0d48 user: jan.nijtmans
2021-06-12
08:46 • Ticket [18f4a94d03]: 3 changes artifact: 5570c998f5 user: bll
08:46 • Add attachment memsocktest.tcl to ticket [18f4a94d03] artifact: e6a2a1a5d8 user: bll
2021-06-11
15:32 • Ticket [18f4a94d03] 8.7 : a blocking memory channel no longer works. status... artifact: 807ad9b838 user: bll
2021-06-10
15:16 • Ticket [18f4a94d03]: 3 changes artifact: ee838118b0 user: bll
12:30 • Ticket [18f4a94d03]: 5 changes artifact: fd54840ac6 user: bll
2021-06-09
19:16 • New ticket [18f4a94d03]. artifact: 527bfc89b5 user: bll

8.7 : a blocking memory channel no longer works.

Closed / Invalid18f4a94d03b075c6295903f1f7b80f7e15b156d6Created 5 years agoUpdated 2 years ago
Descriptionplain2021-06-09 19:16:34
I have some memory channel code that does:

puts $sendchannel some-data  ; # non-blocking
gets $readchannel myvar  ; # blocking, line buffered

This no longer works on macos.  the fileevent on the read handle
is not triggered, and the gets returns an empty string.  

If I put an 'update idletasks' inbetween the puts/gets, it works.

I have not been able to test on Linux as yet.

Edit 1: Changed subject, as this appears to be a problem on both macos and
windows.
Referenced by7
bll Ticket [18f4a94d03]: 5 changes [History diff]2021-06-10 12:30:19
bll Ticket [18f4a94d03]: 3 changes [History diff]2021-06-10 15:16:29
bllplain2021-06-11 15:32:09
Confirmed that this fails on MacOS, Windows and Linux.
bllplain2021-06-12 08:46:47
Attached a non-minimal program that demonstrates the failure.
jan.nijtmanswiki2021-06-15 12:46:17

Thanks for the testcase! I did a bisect with the following result:

 12 BAD     2019-04-24 04:52:22 [9bcec7cd880540c3]
 13 GOOD    2019-04-23 06:50:02 [c4804bce46c2b672]

Conclusion: This [Bugfix] introduced the regression.

Assigning to pouryorick for further analysis.

jan.nijtmanswiki2021-06-15 13:00:25

Proposed fix [here]

jan.nijtmanswiki2021-06-15 14:55:10

Fixed [here]

jan.nijtmans Closed ticket [18f4a94d03]. [History diff]2021-06-15 15:02:16
pooryorickwiki2021-06-16 10:30:32

The behaviour this report describes is not a bug. The provided test sets an event handler but then never enters the event loop:

fileevent $ch readable [list ::memsock::readhandler $ch $port $handler]

This behaviour is not supported. Ad event handler on a channel can not not be processed until the event loop is entered. The example may have worked in previous versions of Tcl, but only because of the bug described in [67a5eabbd3d19591] and [TCL_FILE_EVENTS cannot drive async I/O alone].

In the attached "memsock.test" example, "sendget" relies on this event handler noted above to ferry data between the sending channel and the receiving channel. This is an error. That handler should not be activated until the event loop is entered.

This "memsock.test" example attached to this report is in essence a restatment of [refchan, coroutine, and postevent from the "watch" proc], and that issue was already fixed. Unfortunately, in response to this new issue, that fix was reverted, effectively unfixing issue [67a5eabbd3d19591], and therefore unfixing the real bug illustreated by "memsock.test". The work that was reverted represents an important change in the direction of correcting some fundamental issues in Tcl's IO subsystem. That work should be reinstated immediately so that it makes it into the 8.7 release.

There may indeed be an outstanding issue regarding writing to a nonblocking channel and then attempting to immediately read from it, but such an issue can be fixed far more gracefully than by making the revert in question.

pooryorickwiki2021-06-16 10:34:03

Also, no test case was developed for this report, indicating that an expedient resolution was undertaken rather than a correct one.

jan.nijtmansplain2021-06-16 10:50:28
> There may indeed be an outstanding issue regarding writing to a nonblocking
> channel and then attempting to immediately read from it, but such an issue can
> be fixed far more gracefully than by making the revert in question.

Fully agreed. So, I suggest to fix this outstanding issue, and then put it in again.

Another remark: If this is a bug, it should have been applied to Tcl 8.6 as well. Why wasn't that done at the time? Then this outstanding issue would have been discovered much earlier.

For now (just before Tcl 8.7a5) I agree with reverting this. But - as soon as it is corrected - it should be re-applied, but then to both 8.6 and 8.7
pooryorickwiki2021-06-16 11:26:29

Thank you!

No bug has yet been demonstrated, but I'm working now on a new test case. Perhaps it will expose something.

I used to port more things back to 8.6, but got pushback about making unnecessary changes to a patch release. I no longer want to invest my time in the 8.6 series, but instead focus on 8.7 and above. Other people who care more about 8.6 can port fixes if they consider it worth their time.

pooryorickplain2021-06-16 12:11:45
As was indicated by the original description of resolving the issue using
[update idletasks], what's needed is some event processing between the write to
one channel and the read from the other.  The attached file,
memsock_vwait.test, accomplishes that by entering an event loop at the top
level, scheduling a main coroutine to be run by that event loop, and then
yielding the coroutine at the key moment to allow some event processing.
pooryorickplain2021-06-16 12:13:21
An attempt to reproduce any sort of bug based on the provided description and
attached "memsock.test" was fruitless.  This ticket can be closed as invalid.
pooryorick Closed ticket [18f4a94d03]. [History diff]2021-06-19 21:53:38
jan.nijtmanswiki2024-08-13 19:26:15

Fixed - finally - by reverting [9bcec7cd880540c3]

pooryorickwiki2024-08-18 20:07:06

Even if example script happens to work now, this report is still invalid. As the documentation states, for non-blocking mode to work correctly, the application must be using the Tcl event loop.

jan.nijtmanswiki2024-08-18 20:24:14

Setting the "Resolution" field of this ticket to "Invalid" doesn't make this Bug report invalid. @bll, I value this report, I'm glad it's "Fixed".

pooryorickwiki2024-08-19 14:03:41

That's fine as long as people don't expect it to stay "fixed".

Log in (anonymous is fine) to add a comment.

Attachments: