Wasmer: Is forceful termination possible

Created on 9 Apr 2019  ยท  3Comments  ยท  Source: wasmerio/wasmer

Summary

Is there a way to forcefully terminate a running wasm function call.

Additional details

Currently when a module with an infinite loop is run there seems to be no way to interrupt the function call. What would be the best way to guard against this kind of code? Would it make sense to preprocess the wasm module and inject a maybe_halt function call?

(module
  (func $run 
    (loop
      (br 0)
    ))
  (export "run" (func $run))
)
โ“ question

Most helpful comment

Not yet.

An instrumentation framework supporting this kind of code injection is on the roadmap.

All 3 comments

Not yet.

An instrumentation framework supporting this kind of code injection is on the roadmap.

As Iosfair said, we don't support this yet. There are a couple of approaches we could take here.

We can inject a signal into the thread running the wasm, but there may be undefined behavior and whatnot if we interrupt a host function.

We could also inject an access to a specific, preknown memory page into the trailing edges of loops and function calls that will normally get passed through the cpu pipeline without much ado, but we can then unmap that page and trigger a signal on that thread.

@fd @losfair @lachlansneff Have a look at https://github.com/ewasm/wasm-metering - which injects calls to metering functions before each block.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ensch picture ensch  ยท  5Comments

danchitnis picture danchitnis  ยท  4Comments

geloizi picture geloizi  ยท  4Comments

asaaki picture asaaki  ยท  3Comments

RReverser picture RReverser  ยท  4Comments