Skip to content

ext_proc: Refactor startStream logic and fix crash issue - #28424

Merged
yanavlasov merged 5 commits into
envoyproxy:mainfrom
tyxia:extProcFix
Jul 18, 2023
Merged

yanavlasov merged 5 commits into
envoyproxy:mainfrom
tyxia:extProcFix

Conversation

@tyxia

@tyxia tyxia commented Jul 16, 2023 •

Copy link
Copy Markdown
Member

Issue:

Full sequence of the events(GetAndFailStreamWithInvalidSever test added in this PR also reproduced this issue):

  1. Try to start gRPC async stream in Filter::openStream
    • gRPC stream failed to start due to error: cluster is not available
  2. onRemoteClose is invoked on gRPC stream error because cluster is not available
    • During onRemoteClose: In closeStream, it is no-op since stream_ is still nullptr, which is because start has not returned yet.
  3. start failed with error but ext_proc’s stream_ pointer is not nullptr now after it returns.

Later:

  1. Filter::onDestroy : filter destroy is invoked from ConnectionManagerImpl::doDeferredStreamDestroy
  2. Filter::closeStream: crash happens here. It access the streamInfo of the gRPC stream that has already been closed onRemoteClose (step 2 above)

Solution:

Refactor the start function to return nullptr (i.e. error status) when the underlying gRPC stream failed to start.

  • startStream : starts underlying gRPC stream(also initialize the other members). Its return bool indicates whether the start succeed or not.
  • Factory create method: Returns ExternalProcessorStreamImpl if startStream succeed, otherwise return nullptr, which represents start failure.

Test:

GetAndFailStreamWithInvalidSever test is added to repro the issue above and confirms the fix. Also, clean up FastFailOrderingTest in ordering test: there is no need to invoke close() etc under this new init/start logic. It should just return nullptr on start failure

Signed-off-by: tyxia <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #28424 was opened by tyxia.

see: more, trace.

@tyxia tyxia changed the title ext_proc: Fix the issue in open stream ext_proc: Refactor startStream logic and fix crash issue Jul 17, 2023
@tyxia
tyxia marked this pull request as ready for review July 17, 2023 14:08
@tyxia
tyxia requested a review from mattklein123 as a code owner July 17, 2023 14:08
@tyxia

tyxia commented Jul 17, 2023

Copy link
Copy Markdown
Member Author

/assign @yanavlasov @htuch

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall approach makes sense.

Signed-off-by: tyxia <[email protected]>

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. @yanavlasov want to also have a quick look?

Signed-off-by: tyxia <[email protected]>
@yanavlasov
yanavlasov merged commit 2b789d0 into envoyproxy:main Jul 18, 2023
michaelfinch added a commit to michaelfinch/envoy that referenced this pull request Jul 19, 2023
* main: (46 commits)
  buffer: Disable second flaky test on windows. (envoyproxy#28483)
  ci/github: Fix repo contexts (envoyproxy#28482)
  ci/github: Minor fix for untrusted code (envoyproxy#28480)
  ci/github: Fixes/cleanups for env and workflows (envoyproxy#28473)
  examples: Warn on `golang-network` flake (envoyproxy#28478)
  build(deps): bump node from 20.3-bullseye-slim to 20.4-bullseye-slim in /examples/shared/node (envoyproxy#28321)
  ecds: add network filter dynamic config provider (envoyproxy#28407)
  deps: bump gRPC to 1.56.2 (envoyproxy#28449)
  Adding disallowed_headers in the ext_proc header forwarding rule. (envoyproxy#28468)
  golang filter: add VirtualClusterName getter (envoyproxy#28406)
  ci/github: Further fixes/cleanups for verify (envoyproxy#28467)
  coverage: Lower `source/common/quic` to fix permafail (93.3) (envoyproxy#28471)
  deps: Bump `rules_python` -> 0.24.0 (envoyproxy#28347)
  ci/github: Fix/improve CI env (envoyproxy#28465)
  improve header matcher output (envoyproxy#28389)
  grpc-patch: fix for oss-fuzz build (envoyproxy#28409)
  ext_proc: Refactor startStream logic and fix crash issue (envoyproxy#28424)
  add switch for setting round trip time to connection info (envoyproxy#28159)
  accesslog: disable resource labels (envoyproxy#28046)
  Remove unused header (envoyproxy#28447)
  ...
@tyxia
tyxia deleted the extProcFix branch August 18, 2023 11:05
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