Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

svm-wasmer vmcalls tests segfault #9

Closed
YaronWittenstein opened this issue Jul 22, 2019 · 1 comment
Closed

svm-wasmer vmcalls tests segfault #9

YaronWittenstein opened this issue Jul 22, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@YaronWittenstein
Copy link
Contributor

YaronWittenstein commented Jul 22, 2019

Here is an example of a test that segfaults:
https://github.com/spacemeshos/svm/blob/master/crates/svm-wasmer/tests/storage.rs#L125

#[test]
fn vmcalls_mem_to_reg_copy_segfaults() {
    let module = wasmer_compile_module_file!("wasm/mem_to_reg_copy.wast");

    let import_object = imports! {
        lazy_create_svm_import_object!(0x12_34_56_78, MemKVStore, MemPages, MemPageCache, 5, 100),

        "svm" => {
            "mem_to_reg_copy" => func!(mem_to_reg_copy),
        },
    };

    let instance = module.instantiate(&import_object).unwrap();

    // initializing memory #0 cells `200..203` with values `10, 20, 30` respectively
    wasmer_ctx_mem_cells_write!(instance.context(), 0, 200, &[10, 20, 30]);

    // asserting register content is empty prior copy
    let reg = wasmer_ctx_reg!(instance.context(), 2, MemPageCache);
    assert_eq!([0, 0, 0, 0, 0, 0, 0, 0], reg.get());

    let do_copy: Func<(i32, i32, i32)> = instance.func("do_copy_to_reg").unwrap();
    assert!(do_copy.call(200, 3, 2).is_ok());

    // asserting register content is `10, 20, 30, 0, ... 0`
    let reg = wasmer_ctx_reg!(instance.context(), 2, MemPageCache);
    assert_eq!([10, 20, 30, 0, 0, 0, 0, 0], reg.get());
}
@YaronWittenstein YaronWittenstein added the bug Something isn't working label Jul 22, 2019
@YaronWittenstein YaronWittenstein self-assigned this Jul 22, 2019
YaronWittenstein added a commit that referenced this issue Jul 22, 2019
* Found a workaround to make the `vmcalls storage` tests pass without raising a SEGFAULT.
* See Issue #9
@YaronWittenstein
Copy link
Contributor Author

Seems this wasmer issue solves the issue:
fix Drop of uninit Ctx; use MaybeUninit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant