Skip to content

test: refactor FakeUpstream to avoid use-after-free when scheduling callbacks for a stream that has been terminated due to timeout. - #16590

Merged
antoniovicente merged 2 commits into
envoyproxy:mainfrom
antoniovicente:fake_upstream_fixes
May 24, 2021

Conversation

@antoniovicente

Copy link
Copy Markdown
Contributor

Commit Message:
test: refactor FakeUpstream to avoid use-after-free and data race on vptr when attempting to schedule callbacks for a stream that has been terminated due to timeout.

This change doesn't reduce the failure rate or time to detect failures caused by undetected connection disconnects that eventually result in failures due to stream timeout, it just makes the failure condition more clear by avoiding undefined behaviors and crashes in the fake upstream.

Risk Level: low (test infrastructure changes)
Testing: existing integration tests
Docs Changes: n/a
Release Notes: n/a
Issue #16493

…vptr when attempting to schedule callbacks for a stream that has been terminated due to timeout.

This change doesn't reduce the failure rate or time to detect failures caused by undetected connection disconnects that eventually result in failures due to stream timeout, it just makes the failure condition more clear by avoiding undefined behaviors and crashes in the fake upstream.

Signed-off-by: Antonio Vicente <[email protected]>
@alyssawilk

Copy link
Copy Markdown
Contributor

Are CI failures real on this one?

@antoniovicente

Copy link
Copy Markdown
Contributor Author

Are CI failures real on this one?

There was one more use-after-free that I didn't notice the first time around. Tests are passing after the most recent change.

{
absl::MutexLock lock(&lock_);
if (saw_reset_) {
if (!parent_.connected() || saw_reset_) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional: might be worth a helper for this given how many places it shows up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can see that as a possible improvement to FakeStream::postToConnectionThread. I'll look into it as a possible followup.

@antoniovicente antoniovicente left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!

{
absl::MutexLock lock(&lock_);
if (saw_reset_) {
if (!parent_.connected() || saw_reset_) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I can see that as a possible improvement to FakeStream::postToConnectionThread. I'll look into it as a possible followup.

@antoniovicente
antoniovicente merged commit 63619d5 into envoyproxy:main May 24, 2021
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
…allbacks for a stream that has been terminated due to timeout. (envoyproxy#16590)

This change doesn't reduce the failure rate or time to detect failures caused by undetected connection disconnects that eventually result in failures due to stream timeout, it just makes the failure condition more clear by avoiding undefined behaviors and crashes in the fake upstream.

Signed-off-by: Antonio Vicente <[email protected]>
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.

3 participants