Stream: git-wasmtime

Topic: wasmtime / PR #2853 debug: Fix frame base memory accesses


view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 12:04):

uweigand opened PR #2853 from debug-deref to main:

When translating a WebAssembly DWARF expression into a native
DWARF expression, care needs to be taken to translate WebAssembly
memory addresses into native memory addresses by adding the base
address. However, some addresses are already native addresses,
so the two cases need to be distinguished. Existing code uses
the "need_deref" flag to do so.

However, this flag seems to be calculated incorrectly in some
cases involving frame base register accesses. For example,
in the test case file tests/all/debug/testsuite/fib-wasm.wasm,
the location of the local parameter "n" is described as:
DW_OP_fbreg + 28
while the frame base register is described as:
DW_OP_WASM_location 0x0 0x3, DW_OP_stack_value

Now, the result of evaluating the DW_OP_WASM_location is a
native memory address (retrieved from a native register or
a native stack slot), so we must not add the memory base.
And indeed, when evaluating the DW_AT_frame_base attribute,
the resulting expression does not have need_deref set.

However, when evaluating the DW_OP_fbreg operation, the
frame base expression is copied, the offset (28) is added,
but then also the need_deref flag is set, causing the
memory base to be added. This seems incorrect. If the
frame base is already a native address, then an offset
relative to the frame base is likewise a native address.

This patch fixes the problem by respecting the need_deref
flag of DW_AT_frame_base when evaluating DW_OP_fbreg.
This fixes the test failure I was seeing on s390x.

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Apr 21 2021 at 16:01):

uweigand closed without merge PR #2853.


Last updated: Oct 23 2024 at 20:03 UTC