Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It would be nice to have a sanitizer that could tell guest program authors where, in the guest program, resources were constructed (or, at least, taken ownership of) and last used, for any resources that have not been dropped at the end of execution.
My current opinion is, I thought this would be pretty easy, and it turns out to be somewhat difficult, and I can't prioritize getting it done right now. Please respond on this PR if you want to pick up working on this.
This is a rapid prototype that I have decided is designed completely wrong. It gives a backtrace in the host, but not the guest.
There are two design problems as currently written:
std::backtrace::Backtrace::force_capture()
), not a guest backtrace. This tells you nothing about where the guest program was in its execution. Wasmtime's backtrace construction requires animpl AsContext
argument, and the site at which these backtraces are captured already has a mut borrow of the AsContextMut, so we can't create a lazy way to capture backtracesInstead, this sanitizer probably be implemented as part of a wasmtime::vm::component::HandleTable, and the plumbing can then all stay internal to wasmtime::component's internals. It would still be messy, but not quite as messy?
Additionally, because I knew this was bogus, the capture of backtraces at every single resource use site, as well as the reporting of leaks, is unconditional on every
wasmtime run
invocation, because I knew this was a throwaway and couldn't be bothered to plumb it through properly. (Additionally the wasip1 ctx stuff in Runner makes it artificially hard.)For this deliberately faulty guest program:
this PR prints: