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 incorrect Windows process waiting #3559

Merged
merged 2 commits into from
May 13, 2020
Merged

Conversation

chalcolith
Copy link
Member

I think there are a couple of problems with recent changes to ponyint_win_process_wait. I should have caught them in review.

Changing the timeout value to 0 means that WaitForSingleObject won't block, so we can't close the handle in that case. Also 0x80 is the return code WAIT_ABANDONED which doesn't apply to processes. We should be checking for WAIT_TIMEOUT (0x102) which means the process hasn't exited yet. Also we need to make sure that retval is not 0 or 1 in an error case where GetLastError() returns 0 for some reason.

I think there are a couple of problems with recent changes to `ponyint_win_process_wait`.

Changing the timeout value to 0 means that `WaitForSingleObject` won't block, so we can't close the handle in that case.  Also 0x80 is the return code `WAIT_ABANDONED` which doesn't apply to processes.  We should be checking for `WAIT_TIMEOUT` (0x102) which means the process hasn't exited yet.  Also we need to make sure that retval is not 0 or 1 in an error case where `GetLastError()` returns 0 for some reason.
@SeanTAllen
Copy link
Member

@kulibali did you verify that this fixes the corral issue:

ponylang/corral#110

if (retval == 0) retval = -1;
}
break;
case WAIT_ABANDONED: // shouldn't happen to a process
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this shouldn't happen, i feel like we should be erroring out or something here so that it straight up dies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I have moved this so it fails.

@SeanTAllen SeanTAllen mentioned this pull request May 13, 2020
@chalcolith
Copy link
Member Author

Yes, from initial testing this seems to fix the Corral issue.

@SeanTAllen
Copy link
Member

@kulibali I'm wary of that "this can't happen" fall through. I'd prefer to not have that. Better to have it complain, die or something. Other than that, I think this is good.

@SeanTAllen SeanTAllen changed the title Clean up Windows process waiting Fix incorrect Windows process waiting May 13, 2020
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label May 13, 2020
@SeanTAllen SeanTAllen merged commit 6d51b56 into master May 13, 2020
@SeanTAllen SeanTAllen deleted the fix_windows_process branch May 13, 2020 01:25
github-actions bot pushed a commit that referenced this pull request May 13, 2020
@mfelsche
Copy link
Contributor

My bad! :( Me trying windows things...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants