Open3

WasmLinux: viでファイルを保存するとクラッシュする

okuokuokuoku

vi動いてるだけで感動もんではあるが、保存するとクラッシュする。

#6  0x0000000100402ec1 in wasm_rt_trap (code=WASM_RT_TRAP_CALL_INDIRECT) at /cygdrive/d/wasmlinux/wabt/wasm2c/wasm-rt-impl.c:75
#7  0x00000001012d0a9b in w2c_kernel_lkl_syscall (instance=0xa00b33a80, var_p0=46, var_p1=2, var_p2=1046739728)
    at /cygdrive/d/wasmlinux/kmdist/kernel.c:1690081
#8  0x00000001012f348a in w2c_kernel_syscall_0 (instance=0xa00b33a80, var_p0=46, var_p1=2, var_p2=1046739728)
    at /cygdrive/d/wasmlinux/kmdist/kernel.c:1702340
#9  0x0000000100404af0 in w2c_kernel_syscall (instance=0xa00b33a80, var_p0=46, var_p1=2, var_p2=1046739728) at /cygdrive/d/wasmlinux/kmdist/kernel.c:191309
#10 0x0000000103759071 in runsyscall32 (no=46, nargs=3, in=1046739728) at /cygdrive/d/wasmlinux/runner/hostrunner/runner.cpp:622
#11 0x0000000103759255 in w2c_env_wasmlinux_syscall32 (env=0x0, argc=3, no=46, args=1046739728) at /cygdrive/d/wasmlinux/runner/hostrunner/runner.cpp:690
#12 0x000000010273e4fe in w2c_busybox__base__w2c_ftruncate (instance=0xa00c23c60, var_p0=5, var_p1=11)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:231657
#13 0x0000000102ab932d in w2c_busybox__base__w2c_file_write (instance=0xa00c23c60, var_p0=950374480, var_p1=950403136, var_p2=950403146)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:520347
#14 0x0000000102a6eb26 in w2c_busybox__base__w2c_colon (instance=0xa00c23c60, var_p0=950363376)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:495897
#15 0x0000000102a86a93 in w2c_busybox__base__w2c_do_cmd (instance=0xa00c23c60, var_p0=58)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:502745
#16 0x0000000102a53669 in w2c_busybox__base__w2c_edit_file (instance=0xa00c23c60, var_p0=1059578275)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:487662
#17 0x0000000102a4dbf0 in w2c_busybox__base__w2c_vi_main (instance=0xa00c23c60, var_p0=2, var_p1=1059578244)
    at /cygdrive/d/wasmlinux/umdist/wasmlinux/modcache/10/dd/be2058cfed14b801f8d6577f8d4896c9e6ae3610bbfe45db61abf7ec5ded/busybox_base_w2c.c:486123

ftruncate の引数の数が正しくないのかな。

okuokuokuoku

ftruncate

https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html

#include <unistd.h>

int ftruncate(int fildes, off_t length);

2引数。ログでもちゃんと2引数にoverrideを掛けている:

(user) syscall = 46
Override syscall args (46: 3 => 2)

... これ64bit版だからwasm32からは2値積まないといけないのでは。。?

https://github.com/okuoku/wasmlinux-runner/blob/e0563acdee619cfd9adfd331d766ccacee740219/hostrunner/kernel_data/syscalls.h#L47