Skip to content
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

Fix ocamltest process termination on Windows #1739

Merged
merged 1 commit into from Apr 26, 2018

Conversation

Projects
None yet
2 participants
@dra27
Copy link
Contributor

commented Apr 26, 2018

This partly addresses the errors detected by AppVeyor in #1730.

@shindere

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2018

Fix ocamltest process termination on Windows
On Windows, a process can become signalled even if child processes it
spawned are still running. Fix this by creating the proces in a job object
and using an I/O completion port to detect when there are no processes
left running in the job.

@dra27 dra27 force-pushed the dra27:ocamltest-windows-job branch from 784ee92 to 3c116ed Apr 26, 2018

@dra27

This comment has been minimized.

Copy link
Contributor Author

commented Apr 26, 2018

Oops - it would appear when I reformatted the commit for line-lengths, I lost a comma. Hopefully that version will pass AppVeyor this time!

@shindere - this issue only comes up if the test in question spawns another process and terminates (for example, by using the exec functions). On Windows, anyone waiting on the original process handle is released at the exec call, because the code doesn't actually replace the executable image. I imagine that either any tests which did this made their output quickly enough that it didn't matter or, more likely, that there were just no tests which were doing this. When the commands are invoked by make, I expect that because it's invoked via a shell, it's doing the same thing somewhere under the hood.

In the end, I found it by getting ocamltest to tell me the actual lines it was reading from the files (the output file didn't have enough lines), then I got ocamltest to do Sys.command ("type \"" ^ file ^ "\"") |> ignore; but that command showed all the lines and finally I guessed it might be a synchronisation/flushing problem and so inserted a 1 second delay before the file comparison and suddenly it worked. Then looking at exec_tests.ml, I realised that the lines were perfectly to do with the "original" process. A fun bit of detective work - I knew about Windows job objects, but they're usually for process management ... this is a slightly different use of them!

@dra27 dra27 merged commit ea0fc8a into ocaml:trunk Apr 26, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@shindere

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2018

@dra27

This comment has been minimized.

Copy link
Contributor Author

commented Apr 27, 2018

@shindere - I'm not 100% on the detail of it, but I think that yes the issue is where the process terminates without waiting for children to terminate - it's just that, unlike on Unix, that includes the result of an exec* call.

I meant to say with the Windows Job objects that they're usually for multi-process management! They allow killing processes as groups and resource limiting between multiple processes and all kinds of other wonderful tricks not really related to the simple question of waiting for one process and everything it's spawned to terminate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.