Skip to content

"Couldn't materialize" error in debugger after indirect call #11337

@catamorphism

Description

@catamorphism

Test Case

function-pointer.wasm.gz

Steps to Reproduce

The .wasm file was created with:

clang --target=wasm32-wasip2 --sysroot=$HOME/wasi-libc/sysroot -o function-pointer.wasm function-pointer.c -g -O0

and wasi-libc was built from source.

function-pointer.c is as follows:

struct myfile {
  int data;
  void (*f)();
} myfile;

void f() {}

int foo(struct myfile* f1) {
    f1->f();
    // If the above line is commented out and the next line is uncommented,
    // it works as expected
    // f()
    if (f1->data == 42)
        return 0;
    return 1;
}

int main() {
    struct myfile f1;
    f1.f = &f;
    f1.data = 42;
    return foo(&f1);
}

Steps:

lldb -- wasmtime run -D debug-info -O opt-level=0 --wasm component-model --dir .::/ function-pointer.wasm
(lldb) b foo
(lldb) run
(lldb) p f1
(WebAssemblyPtrWrapper<myfile>)  (__ptr = 199872)
(lldb) n
(lldb) p f1
error: Couldn't materialize: couldn't get the value of variable f1: variable not available
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

Expected Results

I would expect to be able to view f1 in the debugger at any point during the execution of foo().

Actual Results

"Couldn't materialize" error as above.

Versions and Environment

Wasmtime version or commit: 35.0.0

lldb version: 18.1.3

Operating system: Linux (Ubuntu 24.04)

Architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingcranelift:area:debugwasmtime:debuggingIssues related to debugging of JIT'ed code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions