question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implementing an interposer

See original GitHub issue

I wanted to use wasmtime-py to implement a tool similar to ltrace that intercepts WASI calls. Here’s the key part of my code:

def trace(name, orig):
	def trace_fn(*args):
		rets = orig(*args)
		print("{}{!r}->{!r}\n".format(name, args, rets))
		return rets
	return trace_fn
wasi = wasmtime.WasiInstance(store, "wasi_snapshot_preview1", wasi_cfg)
imports = []
for import_ in module.imports():
	if import_.module() == "wasi_snapshot_preview1":
		export = wasi.bind(import_)
		import_type = import_.type().func_type()
		wrapper = wasmtime.Func(store, import_type, trace(import_.name(), export))
		imports.append(wrapper.as_extern())
instance = wasmtime.Instance(module, imports)
instance.get_export("_start")()

However, this crashes almost instantly with a nested trap. I think this happens because the WASI implementation is internally using something like access_caller=True in order to access the memory, since the pointer-like WASI arguments are just indexes into that. But it seems like there’s no way to pass the Caller along.

Is there a good way to implement such functionality regardless?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alexcrichtoncommented, Apr 28, 2020

I don’t believe the C API currently ever initializes the log levels, but that seems plausible to add! I’ll file a PR for that

0reactions
alexcrichtoncommented, May 21, 2020

Ok!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Architecting Interposers - Semiconductor Engineering
The task the interposer performs is to electrically connect signals in different chips/chiplets. “Typically, interposers provide a bridge ...
Read more >
What Is an Interposer? - Technipages
An interposer is an intermediary between the package substrate and the CPU die. It's typically made of silicon. It offers good thermal stability ......
Read more >
Interposer - Wikipedia
An interposer is an electrical interface routing between one socket or connection to another. The purpose of an interposer is to spread a...
Read more >
Implementation of active interposer for high-speed and low ...
This paper describes the prototype demonstration of the active interposers assembled on the waveguide film-laminated printed circuit boards. Processing and test ...
Read more >
Heterogeneous Integration Using Organic Interposer ...
As the costs of advanced node silicon have risen sharply with the 7 and 5-nanometer nodes, advanced packaging is coming to a crossroad...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found