|
2008-04-04
| ||
| 01:08 | • Closed ticket [1932639fff]: Mixed sync/async fcopy -command plus 3 other c... artifact: 74978be509 user: andreas_kupries | |
| 01:08 | • Ticket [1932639fff]: 4 changes artifact: 634cc293d1 user: andreas_kupries | |
| 00:42 | • Ticket [1932639fff]: 4 changes artifact: fab710aa66 user: andreas_kupries | |
| 00:42 | • Add attachment final-fcopy-async-patches.tar.gz to ticket [1932639fffff... artifact: 51e390e919 user: andreas_kupries | |
|
2008-04-03
| ||
| 16:49 | • Ticket [1932639fff] Mixed sync/async fcopy -command status still Open with... artifact: 90a6f4510c user: ferrieux | |
| 16:49 | • Add attachment fcasync.tcl to ticket [1932639fff] artifact: 06542e7e49 user: ferrieux | |
| 06:37 | • Ticket [1932639fff] Mixed sync/async fcopy -command status still Open with... artifact: f25cb30806 user: andreas_kupries | |
| 05:46 | • Ticket [1932639fff]: 4 changes artifact: 45368b51c8 user: andreas_kupries | |
| 05:46 | • Add attachment fcopy-async-tcl8.6.patch to ticket [1932639fffffffff|193... artifact: 0b71e3e604 user: andreas_kupries | |
| 05:45 | • Add attachment fcopy-async-tcl8.5.patch to ticket [1932639fffffffff|193... artifact: b2bcc311de user: andreas_kupries | |
| 05:45 | • Ticket [1932639fff] Mixed sync/async fcopy -command status still Open with... artifact: 4ddd3e0c43 user: andreas_kupries | |
| 05:45 | • Ticket [1932639fff]: 4 changes artifact: 1bcbc4670b user: andreas_kupries | |
| 05:45 | • Add attachment fcopy-async-tcl8.4.patch to ticket [1932639fffffffff|193... artifact: acd1e4bc8e user: andreas_kupries | |
| 05:45 | • Ticket [1932639fff] Mixed sync/async fcopy -command status still Open with... artifact: 142301982e user: andreas_kupries | |
| 05:02 | • Add attachment fcopy-async.patch to ticket [1932639fffffffff|1932639fff... artifact: 9d1a7ed101 user: ferrieux | |
| 05:02 | • Ticket [1932639fff] Mixed sync/async fcopy -command status still Open with... artifact: 5d71f0b41f user: ferrieux | |
|
2008-04-02
| ||
| 20:49 | • New ticket [1932639fff]. artifact: 7b19a96058 user: ferrieux | |
Mixed sync/async [fcopy -command]
Closed / Fixed1932639fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-04-02 20:49:20
In the course of the investigation for [Bug 780533], I
stumbled upon the following weirdness of the implementation (quoting
myself since nobody answered that part ;-):
> A side-note about the implementation: if I read correctly, the
> asynchronous [fcopy] does its first chunk synchronously (in
> non-blocking mode). This is a bit unusual in event-driven style: setup
> procedures just set things up, the real work being done only from
> within [vwait]. While here, a small bit of the copy may be done
> immediately, even if the program doesn't call vwait before some
> time...
> Why is it done this way ? To factor code between sync and async cases ?
> Do we want it to be this way ? Could it explain nasty context-dependent bugs ?
Now, I'd like to pour in additional evidence that this is just plain wrong.
The idea is that, since [fcopy -command] is both sync and async, an
error raised in the callback may pop out either synchronously (subject
to a catch on [fcopy] itslef) or asynchronously (subject to bgerror):
1) Fast transfer (2 bytes):
% proc plop args {puts stderr PLOP:$args;set ::done 1;error yo}
% set f [open ha r]
% set n [open nul: w]
% fconfigure $f -translation binary
% fconfigure $n -translation binary
% fcopy $f $n -size 2 -command plop
PLOP:2
% puts $::errorInfo
while executing
"fcopy $f $n -size 2 -command plop"
(notice also that the error status is lost, while errorInfo is OK. Yet
another bug.)
2) Slow transfer (20000 bytes)
# do the same with -size 20000 and a file longer than that
- fcopy returns control without PLOP
- you need to enter a vwait to get the PLOP
(yuck -- the error is lost again; but if it wasn't, it'd be a bgerror)
Questions:
- Is the disabling of errors in the callback intentional, in order to
hide that catch/bgerror dichotomy ?
- If not, would you accept a patch straightening both issues simultaneously by:
- removing the sync part of [fcopy -async]
- re-enabling errors in the callback (hell if I know how to do
this right now)
This way, both examples above would end up in bgerror.
(Needless to say, I volunteer for the patch)
ferrieuxplain2008-04-03 05:02:41
File Added - 272954: fcopy-async.patch
Logged In: YES
user_id=496139
Originator: YES
Fixed.
The attached patch fixes the issue of unwanted synchronous part.
The error suppression in the sync case was due to the fact that the code always called TclBackgroundException, regardless of the potentially synchronous status. This makes me think that the synchronous part was not intentional.
The bgerror works now. I mistakenly thought there was also error suppression in that case, dur to yet anothe bug not yet entered (the strange lappend-like concatenation of arguments to the callback, preventing callbacks like {puts FOO;error BAR}).
The patch is against vanilla code (without the -command patch), and includes the -command patch.
If you apply it against patched version, prepare for and ignore a failed hunk on the cmdPtr test.
Test suite OK.
File Added: fcopy-async.patch
andreas_kupriesplain2008-04-03 05:45:27
File Added - 272961: fcopy-async-tcl8.4.patch
andreas_kupriesplain2008-04-03 05:45:28
Logged In: YES user_id=75003 Originator: NO File Added: fcopy-async-tcl8.4.patch
andreas_kupriesplain2008-04-03 05:45:57
File Added - 272962: fcopy-async-tcl8.5.patch Logged In: YES user_id=75003 Originator: NO File Added: fcopy-async-tcl8.5.patch
andreas_kupriesplain2008-04-03 05:46:14
File Added - 272963: fcopy-async-tcl8.6.patch Logged In: YES user_id=75003 Originator: NO File Added: fcopy-async-tcl8.6.patch
andreas_kupriesplain2008-04-03 06:37:48
Logged In: YES user_id=75003 Originator: NO Confirm that patched Tcl core passes the regular testsuite. Tested for 8.4, 8.5, Head, non-threaded, non-debug build, linux. Alexandre, do you have a small test script we could add to the testsuite, which demos the new bgerror handling (and would fail pre-patch)?
ferrieuxplain2008-04-03 16:49:40
File Added - 273031: fcasync.tcl Logged In: YES user_id=496139 Originator: YES Attaching a test script. It tests two separate things: (1) suppression of the synchronous part (2) bgerror. What you will see, is that (1) was clearly not working before the patch (detected by the growth of the output file), but (2) worked anyway because of the other bug prevented the callback from firing in the synchronous part ! Of course, my previous patch made (2) reappear :-) In summary: - use stock Tcl to see 1=FAILURE 2=SUCCESS - use [-command] patch to see 1=FAILURE 2=FAILURE - use this patch to see 1=SUCCESS 2=SUCCESS File Added: fcasync.tcl
andreas_kupriesplain2008-04-04 00:42:40
File Added - 273099: final-fcopy-async-patches.tar.gz Logged In: YES user_id=75003 Originator: NO File Added: final-fcopy-async-patches.tar.gz
andreas_kupriesplain2008-04-04 01:08:05
Logged In: YES user_id=75003 Originator: NO Well, the final patches are not quite final. For 8.5/Head copy the nerw testcase to chanio.test and tweak a bit for use of the 'chan' command. committed to 8.4, 8.5, and Head. All passing the extended testsuite.
andreas_kupries Closed ticket [1932639fff].
[History diff]2008-04-04 01:08:06
Log in (anonymous is fine) to add a comment.
Attachments:
- final-fcopy-async-patches.tar.gz [download] added by andreas_kupries on 2008-04-04 00:42:40. [details]
- fcasync.tcl [download] added by ferrieux on 2008-04-03 16:49:39. [details]
- fcopy-async-tcl8.6.patch [download] added by andreas_kupries on 2008-04-03 05:46:13. [details]
- fcopy-async-tcl8.5.patch [download] added by andreas_kupries on 2008-04-03 05:45:57. [details]
- fcopy-async-tcl8.4.patch [download] added by andreas_kupries on 2008-04-03 05:45:27. [details]
- fcopy-async.patch [download] added by ferrieux on 2008-04-03 05:02:41. [details]