Skip to content

wasm: fix root_context_id that was incorrectly cached across threads.#15016

Merged
lizan merged 8 commits intoenvoyproxy:mainfrom
PiotrSikora:wasm-fix_cached_root_context_id
Feb 17, 2021
Merged

wasm: fix root_context_id that was incorrectly cached across threads.#15016
lizan merged 8 commits intoenvoyproxy:mainfrom
PiotrSikora:wasm-fix_cached_root_context_id

Conversation

@PiotrSikora
Copy link
Contributor

Fixes proxy-wasm/proxy-wasm-cpp-host#125.

Signed-off-by: Piotr Sikora piotrsikora@google.com

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Feb 10, 2021
@repokitteh-read-only
Copy link

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).

🐱

Caused by: #15016 was opened by PiotrSikora.

see: more, trace.

@PiotrSikora
Copy link
Contributor Author

cc @bianpengyuan

@PiotrSikora
Copy link
Contributor Author

/backport

@repokitteh-read-only repokitteh-read-only bot added the backport/review Request to backport to stable releases label Feb 10, 2021
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
bianpengyuan
bianpengyuan previously approved these changes Feb 10, 2021
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Copy link
Contributor

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

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

drive by comments.

}
if (plugin_->fail_open_ && (!wasm || wasm->isFailed())) {
return nullptr;
if (!wasm || wasm->isFailed()) {
Copy link
Member

Choose a reason for hiding this comment

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

question: is this change something to do with #14947?

Copy link
Contributor Author

@PiotrSikora PiotrSikora Feb 11, 2021

Choose a reason for hiding this comment

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

No, there are functional changes here, only style.

Previously, we had:

if (plugin_->fail_open_ && (!wasm || wasm->isFailed())) {
  return nullptr;
}

which handled the fail open case, and

return std::make_shared<Context>(wasm, root_context_id_, plugin_);

which handled both the valid case, and the fail closed case (where wasm == nullptr and the rest didn't matter).

I've split the latter to make it more readable, since the new version is:

return std::make_shared<Context>(wasm, handle->configId(), plugin_);

and handle isn't valid in the fail closed case.

Alternatively, I could undo the style changes and turn this into:

return std::make_shared<Context>(wasm, handle.has_value() ? handle->configId() : 0, plugin_);

but that seems more confusing than having separate codepath.

Let me know what you prefer.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
@PiotrSikora PiotrSikora marked this pull request as ready for review February 11, 2021 15:35
@PiotrSikora PiotrSikora requested a review from lizan as a code owner February 11, 2021 15:35
@PiotrSikora PiotrSikora changed the title wasm: fix config_id that was incorrectly cached across threads. wasm: fix root_context_id that was incorrectly cached across threads. Feb 11, 2021
Copy link
Member

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@PiotrSikora
Copy link
Contributor Author

@envoyproxy/dependency-shepherds PTAL

@moderation
Copy link
Contributor

/lgtm deps

@repokitteh-read-only repokitteh-read-only bot removed the deps Approval required for changes to Envoy's external dependencies label Feb 12, 2021
@Shikugawa Shikugawa removed the backport/review Request to backport to stable releases label Feb 15, 2021
@Shikugawa Shikugawa added the backport/approved Approved backports to stable releases label Feb 15, 2021
@lizan lizan merged commit c8fb3a5 into envoyproxy:main Feb 17, 2021
PiotrSikora added a commit to PiotrSikora/envoy that referenced this pull request Feb 17, 2021
lizan pushed a commit that referenced this pull request Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/approved Approved backports to stable releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wasm VM corruption on plugin config update

7 participants