Stop a test if one of the threads terminated because of an error - #1654
Stop a test if one of the threads terminated because of an error#1654davidBar-On wants to merge 1 commit into
Conversation
cf29e22 to
6d22cb6
Compare
|
Thanks for the pull request! This change looks interesting, but it requires a closer look and might take us a bit more time to look at it. |
6d22cb6 to
6c15de2
Compare
c7326af to
d7ab071
Compare
|
Hi, thanks for working on this. I reproduced the underlying missing worker-to-main-loop propagation on current The fault injector keeps the control socket and second data stream live, selects the first data socket after the control connection, lets 31 The PR detects both worker failures, but I found these regressions:
This replaces the root transfer error with a secondary
The worker is classifying an expected teardown race as a transfer failure. There are two related ownership problems in the current approach:
The reconstructed candidate built successfully, Would it make sense to keep worker completion as test- or stream-owned synchronized state containing the first exact I checked the existing PR body and discussion; these current-master reproduction results and regressions were not already reported. DisclosureInvestigated thoroughly with GPT-5.6 (extra high reasoning effort), using Oh My Pi as the agent framework. This report is not generic or unreviewed AI-generated output. Its claims were checked against the cited evidence, and it includes the relevant detail intended to help maintainers resolve the issue. If reports like this are not useful to the project, please let me know and I will refrain from submitting similar ones. My intent is to help without wasting maintainer time or energy or discouraging their work. Thank you for your work. |
…y if it was successful
d7ab071 to
4bc0331
Compare
|
@MikeeI thanks for this input. At least for me, as the PR author, it is helpful (I don't know about the iperf3 project in general). Regarding the comments / suggested changes, I implemented some (see for details below). I would appreciate it if you can run this evaluation again on the new commit (assuming it does not use too many tokens ...). One more point that your AI may help with. Although per your results it seems that in general this PR is working well, it disturbs me that the main thread has to "count" the active worker threads, and that it cannot receive a signal directly about failure of one of these threads. If there is a way to do it (which portable in the main OSs) I would be happy to know how. Regarding the suggested changes:
It will take a lot of testing to make sure that setting the error is required only if it is 0. I prefer not to touch that as it seems to be a minor issue. (May be re-considered after the PR is merged.)
I prefer to keep the double cleanup than risking a case were no cleanup will be preformed.
Should be fixed now. Moved setting the thread counter after the thread was successful created.
I don't understand this comment ... If it means that the server does not reset the
While the comment is correct, practically I don't think it is an issue, as the thread counter increases only during the threads creation. Therefore, for simplicity, I won't add the mutex in the main thread.
This is indeed an issue that I overlooked. I now changed the code so the workers errors will only be printed to |
Version of iperf3 (or development branch, such as
masteror3.1-STABLE) to which this pull request applies:master
Issues fixed (if any): Segfault during
cleanup_serverfor bidirectional or with parallel stream tests ended early #1696Brief description of code changes (suitable for use as a commit message):
Suggested enhancement to terminate a test when one of the threads fail. Currently, even with one thread that fails, iperf3 continues to run the test (and reports 0 bytes transferred). The issue was detected while evaluating PR #1616.
UPDATE: Added a fix for #1696 - try to cancel a stream's thread only if it was created. This can happen if the client terminate before all threads for the streams where created.
The suggest fix approach is that both the client and the server will keep a counter for the number of threads running, which is shared by all threads. If a thread encounters an error, it subtract 1 from this counter before terminating. The client/server main loop is checking whether the counter value equals the expected number of threads.
My initially approach was using
pthread_kill(thread, 0)to check whether any of the streams threads terminated. This is a more robust solution, since it also detects termination because of exceptions. However, I thought the overhead of such check is too high. I am not sure whether this is the case, since the check is done in the main thread.