Skip to content

Conversation

@gabivlj
Copy link
Contributor

@gabivlj gabivlj commented Feb 6, 2024

Fixes #298

@gabivlj
Copy link
Contributor Author

gabivlj commented Feb 7, 2024

Hi @tomhjp! Could you take a look at these changes whenever you have a chance? Thank you!!

@tomhjp
Copy link
Contributor

tomhjp commented Feb 12, 2024

Thanks for the PR and the ping! I'd like to get a test for this fix, please could you share details on a repro? I can reliably repro if similarly to the previous issue I add a time.Sleep(time.Second) inside the stdout scanner loop, but I want to be sure that that's a faithful representation of the real scenario, i.e. is this a race condition that only pops up once in a while, or does it happen every time for your plugin?

@tomhjp
Copy link
Contributor

tomhjp commented Feb 12, 2024

I pushed a test that fails before this fix and passes after in 36c021d. LMK if you think that looks like a good test case.

@gabivlj
Copy link
Contributor Author

gabivlj commented Feb 12, 2024

Thank you @tomhjp for the test! I appreciate it a lot.
I think it's a good test case, as it will practically trigger that stderr exits before stdout and call the 'Wait()' syscall before stdout goroutine finishes.

We were encountering these logs "sometimes" in our error reports so it was just noise.

Copy link
Contributor

@tomhjp tomhjp left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for the confirmation! In that case I'm convinced we've understood the bug sufficiently well to merge. I'll add the test in a follow up PR. Thanks again for the fix!

@tomhjp tomhjp merged commit 90c365e into hashicorp:main Feb 12, 2024
@tomhjp tomhjp mentioned this pull request May 10, 2024
hanzei pushed a commit to hanzei/go-plugin that referenced this pull request Oct 17, 2024
…#299)

If the two goroutines are left to race each other, when runner.Wait() wins it will close the file and cause the stdout scanner to log a spurious os.ErrClosed error instead of returning nil after encountering an io.EOF error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error encountered while scanning stdout: file already closed

2 participants