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

invoke on_context_create_ for all root contexts with a same VM ID #64

Merged
merged 2 commits into from
Oct 16, 2020

Conversation

mathetake
Copy link
Contributor

@mathetake mathetake commented Oct 5, 2020

Fix the bug in using a samewasm file for multiple times with a same VM ID:

  • on_context_create_ is invoked only for the first root context (this is because on_context_create_ is executed in onStart)
  • onConfigure is executed for the other root contexts without invoking on_context_create_,

As far as I know, this results in panics in Rust and TinyGo SDKs, and is not the intended behavior.


Signed-off-by: mathetake takeshi@tetrate.io

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Let's add some test too?

@PiotrSikora PTAL.

@PiotrSikora
Copy link
Member

Fix the bug in the shared vm situation:

  • on_context_create_ is invoked only for the first root context (this is because on_context_create_ is executed in onStart)
  • onConfigure is executed for the other root contexts without invoking on_context_create_,

As far as I know, this results in panics in Rust and TinyGo SDKs, and is not the intended behavior.

I think this is fine, but what exactly do you mean by the "Shared VM" situation? Are you loading different .wasm files into the same WasmVm? Or the same .wasm file with multiple plugins within?

@mathetake
Copy link
Contributor Author

mathetake commented Oct 11, 2020

I mean the same .wasm file with the multiple plugin within or the same .wasm behaving differently corresponding to the plugin configurations. AFAIK, using different wasm files with same VM ID introduces unexpected behavior and is not supported. Is that correct? Anyway, I changed the PR's title and description for clarity.Thanks!

@mathetake mathetake changed the title invoke on_context_create_ for multiple root contexts in the shared VM situation invoke on_context_create_ for multiple root contexts with a same VM ID Oct 12, 2020
@mathetake mathetake changed the title invoke on_context_create_ for multiple root contexts with a same VM ID invoke on_context_create_ for all root contexts with a same VM ID Oct 12, 2020
@PiotrSikora
Copy link
Member

Let's add some test too?

In interest of unblocking this, are we waiting for any tests in this PR?

@PiotrSikora
Copy link
Member

I mean the same .wasm file with the multiple plugin within or the same .wasm behaving differently corresponding to the plugin configurations. AFAIK, using different wasm files with same VM ID introduces unexpected behavior and is not supported. Is that correct?

Correct, it's not supported, since then different allocators wouldn't know about allocations done by other plugins and would overwrite each other's memory. I just wanted to make sure that's not something you wanted to try to support with "shared VMs". Thanks for claryfing.

@mathetake
Copy link
Contributor Author

mathetake commented Oct 13, 2020

In interest of unblocking this, are we waiting for any tests in this PR?

Sorry @PiotrSikora, I have no plan to implement the test in this PR since it requires a lot of work as I discussed with @lizan privately. Is that ok for you?

But I desperately want to have test infrastructure in this repository like the comment here (#47 (comment)).

@lizan
Copy link
Member

lizan commented Oct 14, 2020

Yeah given the test situation in this repo I think it's fine as long as we will test this in Envoy or other wasm hosts.

@PiotrSikora
Copy link
Member

Fix the bug in using a samewasm file for multiple times with a same VM ID:

  • on_context_create_ is invoked only for the first root context (this is because on_context_create_ is executed in onStart)
  • onConfigure is executed for the other root contexts without invoking on_context_create_,

As far as I know, this results in panics in Rust and TinyGo SDKs, and is not the intended behavior.

Isn't the real issue here that onCreate() isn't called before onConfigure() in the host code? Could you look at how feasible is fixing that instead of adding this workaround in onConfigure()?

@mathetake
Copy link
Contributor Author

Isn't the real issue here that onCreate() isn't called before onConfigure() in the host code?

I just quick looked over the Envoy's implementation, but onConfigure is not directly executed there. IIUC, instead, it is executed deeply inside of the getOrCreateThreadLocalWasm implemented in this proxy-wasm-cpp-host repo.

@mathetake
Copy link
Contributor Author

mathetake commented Oct 14, 2020

but yeah it seems natural to me to allow host implementations to determine when to execute onStart and onConfigure instead of implicitly invoking them during the VM creation/getter. I think it requires a little bit of refactoring here

@PiotrSikora
Copy link
Member

Let's merge this as-is for now, since it fixes a crash, and we can do refactoring in a separate PR.

@mathetake
Copy link
Contributor Author

Let's merge this as-is for now, since it fixes a crash, and we can do refactoring in a separate PR.

agreed

src/context.cc Show resolved Hide resolved
Signed-off-by: mathetake <takeshi@tetrate.io>
Signed-off-by: mathetake <takeshi@tetrate.io>
src/context.cc Show resolved Hide resolved
src/context.cc Show resolved Hide resolved
@mathetake
Copy link
Contributor Author

mathetake commented Oct 16, 2020

@PiotrSikora I verified this change resolves the original issue and works fine with my local tests without crashing (Hopefully we will test them in this repository's CI in the future)

@PiotrSikora PiotrSikora merged commit c5658d3 into proxy-wasm:master Oct 16, 2020
@PiotrSikora
Copy link
Member

Thanks! Could you pull those changes into Envoy?

@mathetake
Copy link
Contributor Author

OK, will do!

htuch pushed a commit to envoyproxy/envoy that referenced this pull request Oct 16, 2020
The PR updates proxy-wasm-cpp-host dependency for enhancing the capability and fixing a bug in WASM extensions.

The change consists of three PRs in proxy-wasm-cpp-host:

1. proxy-wasm/proxy-wasm-cpp-host#68 @PiotrSikora
2. proxy-wasm/proxy-wasm-cpp-host#65 @mathetake (me)
3. proxy-wasm/proxy-wasm-cpp-host#64 @mathetake (me)

The code change can be found at proxy-wasm/proxy-wasm-cpp-host@49ed20e...c5658d3 .

1 & 2 enhance WASM capability, and 3 fixes a bug in situations where users share vm_id for multiple filters. For details, please take a look at these original PRs.

Signed-off-by: mathetake <takeshi@tetrate.io>
PiotrSikora pushed a commit to PiotrSikora/envoy that referenced this pull request Nov 19, 2020
The PR updates proxy-wasm-cpp-host dependency for enhancing the capability and fixing a bug in WASM extensions.

The change consists of three PRs in proxy-wasm-cpp-host:

1. proxy-wasm/proxy-wasm-cpp-host#68 @PiotrSikora
2. proxy-wasm/proxy-wasm-cpp-host#65 @mathetake (me)
3. proxy-wasm/proxy-wasm-cpp-host#64 @mathetake (me)

The code change can be found at proxy-wasm/proxy-wasm-cpp-host@49ed20e...c5658d3 .

1 & 2 enhance WASM capability, and 3 fixes a bug in situations where users share vm_id for multiple filters. For details, please take a look at these original PRs.

Signed-off-by: mathetake <takeshi@tetrate.io>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
istio-testing pushed a commit to istio/envoy that referenced this pull request Nov 20, 2020
* build: update rules_rust to allow Rustc in RBE (envoyproxy#13595)

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>

* fix macos v8 build (envoyproxy#13572)

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>

* wasm: update proxy-wasm-cpp-host (envoyproxy#13606)

The PR updates proxy-wasm-cpp-host dependency for enhancing the capability and fixing a bug in WASM extensions.

The change consists of three PRs in proxy-wasm-cpp-host:

1. proxy-wasm/proxy-wasm-cpp-host#68 @PiotrSikora
2. proxy-wasm/proxy-wasm-cpp-host#65 @mathetake (me)
3. proxy-wasm/proxy-wasm-cpp-host#64 @mathetake (me)

The code change can be found at proxy-wasm/proxy-wasm-cpp-host@49ed20e...c5658d3 .

1 & 2 enhance WASM capability, and 3 fixes a bug in situations where users share vm_id for multiple filters. For details, please take a look at these original PRs.

Signed-off-by: mathetake <takeshi@tetrate.io>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>

* wasm: re-enable tests with precompiled modules. (envoyproxy#13583)

Fixes envoyproxy#12335.

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

* wasm: flip the meaning of the "repository" in envoy_wasm_cc_binary(). (envoyproxy#13621)

Change the meaning of the "repository" parameter to refer to an external
Bazel repository, instead of using "@envoy" in targets that are included
in the Envoy repository.

This aligns with other envoy_* rules.

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

* build: support ppc64le with wasm (envoyproxy#13657)

The build has only been tested with gn git sha 5da62d5 as
recommended by ppc64 maintainers of the v8 runtime.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>

* wasm: remove no longer needed Emscripten metadata. (envoyproxy#13667)

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

* fix wasm compilation (envoyproxy#13765)

Signed-off-by: Asra Ali <asraa@google.com>

* wasm: strip only Custom Sections with precompiled Wasm modules. (envoyproxy#13775)

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

* build: don't build shared libraries for zlib and zlib-ng. (envoyproxy#13652)

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

* wasm: update V8 to v8.7.220.10. (envoyproxy#13568)

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

* build: exclude wee8/out from inputs (envoyproxy#13866)

If you build without sandboxing for performance, the output files from
this custom build genrule contained timestamps which caused it to
rebuild every single build.

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>

* tls: fix detection of the upstream connection close event. (envoyproxy#13858)

Fixes envoyproxy#13856.

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

* wasm: Force stop iteration after local response is sent (envoyproxy#13930)

Resolves envoyproxy#13857

ref:
-proxy-wasm/proxy-wasm-rust-sdk#44
-proxy-wasm/proxy-wasm-cpp-host#88
-proxy-wasm/proxy-wasm-cpp-host#93

Signed-off-by: mathetake <takeshi@tetrate.io>
Signed-off-by: Piotr Sikora <piotrsikora@google.com>

* wasm: fix order of callbacks for paused requests. (envoyproxy#13840)

Fixes proxy-wasm/proxy-wasm-rust-sdk#43.

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

* wasm: fix network leak (envoyproxy#13836)

Signed-off-by: Kuat Yessenov <kuat@google.com>

Co-authored-by: Lizan Zhou <lizan@tetrate.io>
Co-authored-by: Rama Chavali <rama.rao@salesforce.com>
Co-authored-by: Takeshi Yoneda <yoneda.takeshi.md@alumni.tsukuba.ac.jp>
Co-authored-by: cmluciano <cmluciano@us.ibm.com>
Co-authored-by: asraa <asraa@google.com>
Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
Co-authored-by: Kuat <kyessenov@users.noreply.github.com>
rexengineering pushed a commit to rexengineering/istio-envoy that referenced this pull request Oct 15, 2021
The PR updates proxy-wasm-cpp-host dependency for enhancing the capability and fixing a bug in WASM extensions.

The change consists of three PRs in proxy-wasm-cpp-host:

1. proxy-wasm/proxy-wasm-cpp-host#68 @PiotrSikora
2. proxy-wasm/proxy-wasm-cpp-host#65 @mathetake (me)
3. proxy-wasm/proxy-wasm-cpp-host#64 @mathetake (me)

The code change can be found at proxy-wasm/proxy-wasm-cpp-host@49ed20e...c5658d3 .

1 & 2 enhance WASM capability, and 3 fixes a bug in situations where users share vm_id for multiple filters. For details, please take a look at these original PRs.

Signed-off-by: mathetake <takeshi@tetrate.io>
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.

None yet

3 participants