|
2011-09-20
| ||
| 02:18 | • Closed ticket [3408824fff]: iocmd.tf-24.16 unstable w/ -DPURIFY plus 4 other... artifact: 51162e918d user: ferrieux | |
| 02:10 | • Open ticket [3408824fff]. artifact: 7e33a009c5 user: ferrieux | |
| 01:20 | • Closed ticket [3408824fff]. artifact: 1e2e740be2 user: dgp | |
| 00:51 | • Ticket [3408824fff]: 4 changes artifact: 7140a2eaba user: andreas_kupries | |
|
2011-09-19
| ||
| 02:15 | • Ticket [3408824fff]: 4 changes artifact: 64518120f4 user: dgp | |
|
2011-09-18
| ||
| 16:01 | • Ticket [3408824fff]: 4 changes artifact: c3fdcce807 user: ferrieux | |
| 07:29 | • Ticket [3408824fff]: 4 changes artifact: 6c8e8a8520 user: andreas_kupries | |
| 07:28 | • Ticket [3408824fff]: 4 changes artifact: 7308304899 user: andreas_kupries | |
| 04:13 | • Ticket [3408824fff]: 4 changes artifact: b8710e15db user: ferrieux | |
|
2011-09-17
| ||
| 17:15 | • Ticket [3408824fff]: 4 changes artifact: 8285b6d3fd user: ferrieux | |
| 17:11 | • Ticket [3408824fff]: 4 changes artifact: 9a6ea1babf user: ferrieux | |
| 03:15 | • Ticket [3408824fff]: 4 changes artifact: 00554e5bf6 user: dgp | |
| 01:44 | • Ticket [3408824fff]: 4 changes artifact: e8862e7237 user: dgp | |
|
2011-09-14
| ||
| 04:31 | • Ticket [3408824fff]: 4 changes artifact: fa8ad50855 user: andreas_kupries | |
| 02:32 | • Ticket [3408824fff]: 4 changes artifact: 966da30b79 user: ferrieux | |
| 01:48 | • Ticket [3408824fff]: 4 changes artifact: 75edcce563 user: dgp | |
| 01:40 | • Ticket [3408824fff]: 4 changes artifact: 34c44a2d64 user: dgp | |
| 01:31 | • Ticket [3408824fff]: 4 changes artifact: 3aee8990b1 user: andreas_kupries | |
| 01:19 | • Ticket [3408824fff]: 4 changes artifact: 758802e338 user: dgp | |
| 01:17 | • Ticket [3408824fff]: 4 changes artifact: c0474bf12e user: ferrieux | |
| 00:57 | • Ticket [3408824fff]: 4 changes artifact: 27b172193a user: dgp | |
| 00:56 | • Ticket [3408824fff]: 4 changes artifact: ec9ef2a0db user: dgp | |
|
2011-09-13
| ||
| 17:52 | • New ticket [3408824fff]. artifact: ef959412e0 user: dgp | |
iocmd.tf-24.16 unstable w/ -DPURIFY
Closed / Fixed3408824fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-09-13 17:52:08
Working on the tip of the trunk, with a -DPURIFY
--disable-shared --enable-symbols build, when
I invoke the following multiple times:
$ make test-tcl TESTFLAGS="-file ioCmd.test -match iocmd.tf-24.16 -verbose bpste"
I get a variety of results. Often the test just succeeds.
But sometimes I get a test failure summarized:
---- Result was:
{write rc0 ABC} {watch rc0 write} {} BG {write rc0 ABC} BG {finalize rc0}
---- Result should have been (glob matching):
{write rc* ABC} {watch rc* write} {} BG {write rc* ABC}
==== iocmd.tf-24.16 FAILED
and other times I get segfaults and aborts of various kinds.
dgpplain2011-09-14 00:56:03
It's hard to catch the segfaults in a debugger, but the few times I have, they appear to be during thread finalization. I think our "rapid exit without finalize" default mode skips over these failures. So maybe I'm just requesting finalization debugging without realizing it.
dgpplain2011-09-14 00:57:12
The trouble is that starting from a noisy baseline makes the kind of migrations like the [testthread] -> Thread thing I'm attempting more difficult, because I can't easily see whether I'm breaking things.
ferrieuxplain2011-09-14 01:17:40
Yes, the -DPURIFY implies force-finalize. Are you suggesting to make the two orthogonal ? (that's trivial, since ::env(TCL_FINALIZE_ON_EXIT) is already there to explore finalization in production builds.
dgpplain2011-09-14 01:19:41
No, I'm not suggesting anything. I'm just recording my thoughts as I realize that I'm asking for the solution of something hard, not easy. Solve Thread finalization! Now! Then go have lunch.
andreas_kupriesplain2011-09-14 01:31:23
Alexandre, methinks that you misunderstood the 'finalize' in the test result. This is not thread finalization. This is the finalization event send by the machinery for reflected channels when the channel is closed, ordering the Tcl level handler code for the channel to clean itself up. The test itself uses threads to test that the whole machinery works with the channel in thread B and the handler in the thread A, where the channel was created.
dgpplain2011-09-14 01:40:18
I mean both! :)
When the test simply fails, aku is correct
that it's an issue of variation in the way the
channel is closed whether an additional
{finalize *} note gets lappended to the expected result.
However, when I've managed to captured the
segfaults or other aborts, the stack trace has
indicated the problem happens during the
call to Tcl_FinalizeThread().
dgpplain2011-09-14 01:48:05
ferrieux, thanks for the reminder about TCL_FINALIZE_ON_EXIT. Testing with that, but in a build without -DPURIFY, I was never able to make the test fail. However, I was able to see a segfault once. These appear to be two different issues with the one test.
ferrieuxplain2011-09-14 02:32:27
Andreas, indeed I was echoing Don's mention of segfaults, since that's exactly the kind of thing that the 2001201 quick-exit reform was meant to avoid :) Now about that extra BG-finalize in the test output: what about replacing [update] with a more deterministic [vwait something], where $something would be conditioned by the presence of the last flushed byte from the sender ?
andreas_kupriesplain2011-09-14 04:31:42
thread/finalize/segfaults - Oh, ok, then the misunderstanding was mine. I am not exactly sure what you wish to condition on, maybe you can can show me a patch ? I was thinking about using vwait as well, although with a timeout via after if the expected data doesn't arrive within a reasonable time frame (say 2 seconds).
dgpplain2011-09-17 01:44:05
On Mac OS X, this test reliably fails even on a non- PURIFY build.
dgpplain2011-09-17 03:15:43
adding "onfinal; " to [foo] body before "note BG" stops the failure observed on OS X
ferrieuxplain2011-09-17 17:11:22
Instrumenting the unmodified test on entry to both [foo]s:
Succeeding case:
FOO1:initialize rc0 {read write}
FOO1:write rc0 ABC
FOO1:watch rc0 write
FOO2:write rc0 ABC
Failing case:
FOO1:initialize rc0 {read write}
FOO1:write rc0 ABC
FOO1:watch rc0 write
FOO2:write rc0 ABC
FOO2:finalize rc0
ferrieuxplain2011-09-17 17:15:01
Yes, the previous comment was equivalent with the test output :} But adding "onfinal" merely hides the problem: clearly there's a race condition, the finalize method being randomly called or not. Why ?
ferrieuxplain2011-09-18 04:13:56
Note that replacing [update] with [after 200 +vwait] lets the [finalize] occur deterministically. Moreover, all reflected channel handler invocations seem to occur in the main thread, not the spawned-and-reaped one. Is it the intended semantics of [testchannel cut/splice] ?
andreas_kupriesplain2011-09-18 07:28:51
Yes, "testchannel cut/splice" are tcltest's method of moving a channel between threads. The package Thread has the public method, a 'thread transfer' command. Internally both use the same C APIs. For reflected channels specificially we can only move (ownership of) the Channel structures between threads, the Tcl part has to stay behind in the thread the channel was created in, because we do not know what dependencies in terms of code, variables, packages, etc. this part has. When such a separation between the levels happens Events and the Tcl Event Queue are used by the C level to send the necessary instructions to the thread handling the Tcl part instead of invoking the script code on its own, plus mutexes and condition variables to wait and get any results. Everything in tclIORChan.c and tclIORTrans.c which has 'Forward' in the name (regardless of case) is related to this. I would put my eye on the parts interacting with the destruction of threads (cleaning up of structures, events, etc.) as a possible source of the problem.
andreas_kupriesplain2011-09-18 07:29:45
Ok, I hope that helps.
ferrieuxplain2011-09-18 16:01:35
Yes it does, thanks for switching the light on :)
One side question: when designing this, have you considered the following, simpler alternative:
When transferring a RC, in addition to tranferring ownership of the channel as usual, just pass the (string) name of the handler proc "foo". Then make it the script writer's entire responsibility to populate the dest thread with the necessary procs and data for [foo write] et al to be meaningful *there*.
I know it's a bit late to react, sorry. But it seems to me that all the special-casing of "thread-transferring an RC" (the hidden "thread::send + pseudo-vwait", plus all the stuff to encapsulate parameters and results without using cross-interp objects, plus the specific steps to avoid deadlock, etc...) would vanish to be replaced by explicit script-level stuff that is already covered in the existing implementation of the primitives.
What am I missing ?
dgpplain2011-09-19 02:15:53
On the iocmd-leaks branch, I've committed changes to the tests that solve the corruption between them. Since that was my ultimate goal, I no longer care about this bug. I intend to merge the iocmd-leaks branch soon.
andreas_kupriesplain2011-09-20 00:51:38
Alexandre, I don't remember if I considered your alternative. Not surprising, given that it is seven years now since the TIP http://tip.tcl.tk/219.html was made. On re-reading the section regarding the handling of the interaction between RCs and Threads I might have have considered it and discarded, given that I provide a use case for the current design (Using a pair of RCs for stream-based thread communication). Not sure however. > When transferring a RC, in addition to tranferring ownership of the > channel as usual, just pass the (string) name of the handler proc "foo". > Then make it the script writer's entire responsibility to populate the dest > thread with the necessary procs and data for [foo write] et al to be > meaningful *there*. Note that this makes RCs (a) special (case) with regard to transfering between threads. With all other channel types you can simply transfer and them use them. With RCs you now have to perform lots of setup to make it work. In this my approach fits IMVHO better, without special case setup on part of the script writer. The user does not have to care if it is an RC which is transfered, or not. This becomes especially important when your script is an application using channel provided by some library. You usually don't want to know how the channel is implemented, and for this you would have to. > I know it's a bit late to react, sorry. But it seems to me that all the > special-casing of "thread-transferring an RC" (the hidden "thread::send + > pseudo-vwait", plus all the stuff to encapsulate parameters and results > without using cross-interp objects, plus the specific steps to avoid > deadlock, etc...) would vanish to be replaced IOW. the complexity and special casing is not really going away, only simply shifted around and changing its nature a bit (setup with yours vs. all the internal transfer mgmt with mine). > by explicit script-level > stuff that is already covered in the existing implementation of the > primitives.
dgpplain2011-09-20 01:20:31
allow_comments - 1 Robust versions of this test and its neghbors are now merged to trunk from iocmd-leaks branch. These tests now avoid issues where tests can fail due to events from one test corrupting the expected value in another test. There are still some issues with these tests that they can sometimes segfault when in an environment where full thread finalization is being tested. These remaining matters are now the subject of 3411310. The "total re-design" ideas arising now may well be the true answer, but might be better pursued in an RFE Ticket / dev branch of its own.
ferrieuxplain2011-09-20 02:10:48
allow_comments - 0 Andreas, thanks for addressing my points. I don't want to appear as fighting your ideas. It's simply that you are much more courageous than I am :D. Let me just answer a few of your arguments from the lazy man's standpoint: > [use case for interthread comm] Still doable with plain, documented [thread::send] instead of its hidden ersatz inside IORchan, right ? > [orthogonality, channel type agnosticism] Okay but "<@" already exposes the special nature of refchans (and channel transforms, for that matter). Also, while some cases of channel transfer come to mind (like the client socket in a network server), I really can't imagine a modular app ignoring the kind of channel that it's transferring ... and yet accepting the two peculiar consequences of transferring an RC: (a) that the mother thread stays in evloop, and (b) that each and every channel method incurs a round trip to this mother thread. Hardly transparent, I'd say :} > IOW. the complexity and special casing is not really going away, only > simply shifted around and changing its nature a bit (setup with yours vs. > all the internal transfer mgmt with mine). Yes. The key word here is "changing its nature": the burden of setup is entirely in script land ! This means that any complex interactions are emergent properties of the existing primitives, which are covered in dozens of atomic tests, hence much easier to debug : thread::send, vwait, chan create, etc. Moreover, this burden seems much lighter to me. Indeed, instead of emulating the interthread forwarding of refchan methods, one is more likely to just implement them in the other thread, on top of whatever true channel was transferred beforehand. Not much complexity indeed. But I guess it's way too late anyway. Let's hope few deadlocks and race conditions still exist in there ;-)
ferrieux Closed ticket [3408824fff].
[History diff]2011-09-20 02:18:54
Log in (anonymous is fine) to add a comment.