Stream: git-wasmtime

Topic: wasmtime / issue #6707 Allocate file size ?


view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2023 at 09:13):

orangeC23 opened issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 100 7 8 17:03 hello.txt

  3. execute command 'wasmtime run --dir=Data allocate.wasm' and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2023 at 09:13):

orangeC23 labeled issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 100 7 8 17:03 hello.txt

  3. execute command 'wasmtime run --dir=Data allocate.wasm' and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2023 at 09:13):

orangeC23 edited issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 100 7 8 17:03 hello.txt

  3. execute command 'wasmtime run --dir=Data allocate.wasm` and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2023 at 09:14):

orangeC23 edited issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 100 7 8 17:03 hello.txt

  3. execute command wasmtime run --dir=Data allocate.wasm and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 zhangyixuan staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2023 at 13:28):

orangeC23 edited issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 staff 100 7 8 17:03 hello.txt

  3. execute command wasmtime run --dir=Data allocate.wasm and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 10 2023 at 16:24):

pchickey commented on issue #6707:

We dropped support for fd_allocate because it can't be implemented on all platforms: https://github.com/bytecodealliance/wasmtime/pull/6217

view this post on Zulip Wasmtime GitHub notifications bot (Jul 10 2023 at 16:24):

pchickey closed issue #6707:

Test Case

The rust file is :

use std::fs::File;
use std::os::fd::AsRawFd;

fn main() {
    let file = File::open("Data/hello.txt").expect("Can not open.");
    let file_descriptor = file.as_raw_fd();
    println!("File descriptor {}", file_descriptor);

    unsafe{
        let p1:wasi::Fd = file_descriptor as u32;
        let p2:wasi::Filesize = 0;
        let p3:wasi::Filesize = 200;

        println!("{:?}", wasi::fd_allocate(p1, p2, p3).unwrap());
    }
}

Steps to Reproduce

  1. Use cargo build --target wasm32-wasi to compile the rust file into WASM binaries allocate.wasm.
  2. Use command ls -al in directory Data:
    -rw-r--r-- 1 staff 100 7 8 17:03 hello.txt

  3. execute command wasmtime run --dir=Data allocate.wasm and wasmtime crush:

File descriptor 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Errno { code: 58, name: "NOTSUP", message: "Not supported, or operation not supported on socket." }', src/main.rs:14:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: failed to run main module `fd_allocate.wasm`

Caused by:
    0: failed to invoke command default
    1: error while executing at wasm backtrace:
           0: 0x8f5d - <unknown>!__rust_start_panic
           1: 0x8bf8 - <unknown>!rust_panic
           2: 0x8bd3 - <unknown>!std::panicking::rust_panic_with_hook::h8ba9911b0447a950
           3: 0x7f3f - <unknown>!std::panicking::begin_panic_handler::{{closure}}::h853e8c0788d88239
           4: 0x7e6c - <unknown>!std::sys_common::backtrace::__rust_end_short_backtrace::h857cf01eb9e7e44e
           5: 0x84d1 - <unknown>!rust_begin_unwind
           6: 0xe5b2 - <unknown>!core::panicking::panic_fmt::hb51d37ccdc8b549e
           7: 0x1092b - <unknown>!core::result::unwrap_failed::he690a5bf59bc26c4
           8: 0x168d - <unknown>!core::result::Result<T,E>::unwrap::h27b4fd12cf658c2e
           9: 0x104a - <unknown>!fd_allocate::main::h231716c035798af1
          10:  0x808 - <unknown>!core::ops::function::FnOnce::call_once::h3520a35c6b504dcd
          11:  0x4d9 - <unknown>!std::sys_common::backtrace::__rust_begin_short_backtrace::hb84a8edf9d6230fc
          12: 0x179a - <unknown>!std::rt::lang_start::{{closure}}::h8d83b084273b8b6b
          13: 0x529a - <unknown>!std::rt::lang_start_internal::h732a401595f4dfb8
          14: 0x1737 - <unknown>!std::rt::lang_start::heee176ba12f48205
          15: 0x114f - <unknown>!__main_void
          16:  0x490 - <unknown>!_start
       note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
    2: wasm trap: wasm `unreachable` instruction executed
  1. execute command wasmer run --dir=Data allocate.wasm
    wasmer successfully execute the WASM binaries and use command ls -al in directory Data:
    -rw-r--r-- 1 staff 200 7 8 17:05 hello.txt

Thus, wasmtime crush. However, wasmer executed successfully and allocate the size of hello.txt from 100 to 200.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2023 at 04:26):

orangeC23 commented on issue #6707:

We dropped support for fd_allocate because it can't be implemented on all platforms: #6217

Thanks a lot !
Sorry, I have one more question. Should Wasmtime provide a relevant error message when fd_allocate is not supported, instead of panicking directly?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2023 at 05:46):

pchickey commented on issue #6707:

Wasmtime returns Result::Err(Errno::NOTSUP) for that call, which is the appropriate errno. Your wasm program panicked when you called .unwrap() on the Err case.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 11 2023 at 07:45):

orangeC23 commented on issue #6707:

Wasmtime returns Result::Err(Errno::NOTSUP) for that call, which is the appropriate errno. Your wasm program panicked when you called .unwrap() on the Err case.

Thanks a lot !


Last updated: Oct 23 2024 at 20:03 UTC