Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Context-awareness #62

Open
Xe opened this issue Jun 22, 2018 · 6 comments
Open

Context-awareness #62

Xe opened this issue Jun 22, 2018 · 6 comments

Comments

@Xe
Copy link

Xe commented Jun 22, 2018

It would be interesting to provide context-awareness to the exec.VM type. This would check the context Done every so often during execution, and if it is done then a new "took too long" error would be returned to the callee. This would make it possible for users to submit arbitrary untrusted webassembly code for a backend server to run and return the results without as much fear of users submitting code that blocks infinitely.

@ghost
Copy link

ghost commented Jun 24, 2018 via email

@sbinet
Copy link
Contributor

sbinet commented Jun 27, 2018

apologies for the belated answer.

yes, having a context aware exec.VM type would definitely be interesting.

now, the also interesting thing would be to decide until what "depth" we want to weave it through:

  • down to each VM operation? (e.g. pushInt64, i32Load8s, ...)
  • only at VM.ExecCode ?
  • somewhere in the middle?
  • piggy back on what the Go runtime does for preemption ? (ie: only check at the end of loops, function calls, ...)

@Xe
Copy link
Author

Xe commented Jun 28, 2018

  • down to each VM operation? (e.g. pushInt64, i32Load8s, ...)

This would be beyond overkill and would be super performance impactful.

  • only at VM.ExecCode ?

Probably check here too.

  • somewhere in the middle?

I was thinking every n operations or on function/loop/block barriers.

@sbinet
Copy link
Contributor

sbinet commented Jun 29, 2018

down to each VM operation? (e.g. pushInt64, i32Load8s, ...)

This would be beyond overkill and would be super performance impactful.

I agree, I was just being facetious :)

I was thinking every n operations or on function/loop/block barriers.

every n operation is probably simplest to explain and implement, while not being too intrusive.

@Xe
Copy link
Author

Xe commented Jul 5, 2018

How about every 65536 instructions? That constant is already used as the size of a memory page and it's a very nice, even number.

@sbinet
Copy link
Contributor

sbinet commented Jul 5, 2018

SGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants