-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some tests terminate in an unusual manner when canceled #1722
Comments
Hey, nextest author here.
In case of a Ctrl-C, Windows sends the signal to all processes running on the console that don't have a disabled handler. See the note next to On Unix, nextest puts each process in a process group, and is responsible for forwarding signals to test processes. On Windows, nextest does not put processes in Windows's own notion of process group -- not out of principle, but just because I'd like someone with Windows expertise to enumerate and outline all the issues to look for. Test processes can do many weird things, so you have to be quite careful while making changes. See nextest's signal handling docs for more info. These details have been the same for a long time, and haven't changed for 0.9.86. When nextest receives a Ctrl-C, all of the other tests are likely to have received Ctrl-C at the same time as well, and are likely to have immediately exited. Nextest does try to call |
And it suggests a possible improvement in nextest -- maybe on a ctrl-c, nextest should wait for processes to exit by themselves (for the |
Thanks for collecting everything we figured out thus far, @EliahKagan , and great to see @sunshowers chiming in, too!
If that would happen, then it's a bug. For all I know, signal handlers are never installed automatically, nor are they dealt with in any way in plumbing crates. What's interesting is the While all that is happening, |
This sounds right absent something special. Ctrl-C would go to all processes in the console.
So what might be happening, assuming the remote git installs a Ctrl-C handler is:
|
I found this code in git: https://github.com/git/git/blob/2ccc89b0c16c51561da90d21cfbb4b58cc877bf6/compat/mingw.c#L681 Unfortunately, Git is not really a native Windows application, so internally Ctrl-C gets translated via MinGW into SIGINT. This translation layer might be acting up as well.
|
(Like most Rust devtools, nextest is a full-fledged Windows application. There is no attempt to emulate Unix on Windows -- many of the same types are used, but with |
Oh no, I was wrong. In reality, on receiving Ctrl-C, nextest doesn't do anything at all. It just lets tests exit by themselves. See: I actually think this might be wrong -- nextest should probably wait for the grace period and then call My guess right now is that this is a git/mingw issue. But in that case, I'm not quite sure why that code would be reflected in the exit status of the test process. It might be worth installing a Ctrl-C handler in these tests, that just waits a few seconds before terminating or something. edit: Ctrl-C grace periods are implemented in nextest-rs/nextest@66f4a99, which is part of nextest main. It wouldn't have any impact on this issue. |
Even though I don't know why exactly it happens, I don't think a systemic issue should be patched up on the side of the tests. I am willing to live with it, knowing that the |
Ah I meant just for debugging. Agreed that that wouldn't be the right long term fix. |
Discussed in #1414
Originally posted by EliahKagan June 22, 2024
As Raymond Chen has explained in
STATUS_STACK_BUFFER_OVERRUN
doesn’t mean that there was a stack buffer overrun, this condition is misleading and often not nearly as serious as it may seem, because this way of terminating a process on Windows often does not designate any stack overflow, buffer overrun, or any kind of memory-related bug or error. Instead, it is widely used to terminate a program in any kind of critical immediate failure.Nonetheless, I find it odd that I see this when I cancel gitoxide's test suite with Ctrl+C on Windows, since it does not happen when I cancel other Rust projects' tests when running them in the same way.
As noted in this Stack Overflow answer and that Microsoft documentation,
0xc0000409
designates a (user mode)STATUS_STACK_BUFFER_OVERRUN
.When this is produced by a call to the
__fastfail
intrinsic, there is a separate code that provides additional information. I don't know if that's relevant here or how to extract the information. The other error information shown in that test output isos error 1282
which seems to just mean "invalid operation."For contrast, I have tried running
cargo nextest --all --no-fail-fast
and pressing Ctrl+C on that same Windows system for three other projects, all of which showed a more intuitive termination condition and none of which showed0xc0000409
.ripgrep
:rust-bio
:(With various other interrupted tests, with the same message.)
crossbeam
:(With many other interrupted tests, with the same message.)
"Application Exit by CTRL+C" is an intuitive effect of pressing Ctrl+C to cancel tests, while a request for immediate termination--even if not related to any actual memory errors--is less intuitive.
Full output from all four projects tested can be seen in this gist.
I do not assume this is a bug. But I don't want to assume it isn't, unless this can be explained.
The
nextest
documentation notes that it uses Windows job objects to terminate process trees "immediately," which I would be taken to think might explain this behavior if it always or usually happened, but does not explain it given that it seems only to happen with gitoxide.The effect does not appear specific to when tests from any particular crate of gitoxide are running.
Although I believe no signal--in the usual POSIX-related sense--is being used here to terminate the processes. Nonetheless, maybe this has something to do with how gitoxide deals with signals?
I cannot produce this with
cargo test
commands but I don't know if that means it's related tonextest
or instead if justcargo test
does not show enough information about termination to reveal it. Likewise, I do not know if this can happen under any non-test circumstances when running applications that use gitoxide crates.The text was updated successfully, but these errors were encountered: