Skip to content

fd_write crash on send_downstream() when updating to latest Viceroy #5

@erikrose

Description

@erikrose

I was hoping to update to the latest Viceroy WITs and get off the sunfishcode/sync-wit branch, but this happens when serving a request:

% make serve
rm -rf hello_compute
componentize-py -d wit -w compute bindings hello_compute
componentize-py -d wit -w compute componentize --stub-wasi app -o app.wasm
Component built successfully
viceroy --adapt app.wasm
2025-08-29T16:46:00.920215Z ERROR WebAssembly trapped: error while executing at wasm backtrace:
    0: 0x1143b98 - wit-component:adapter:wasi_snapshot_preview1!<wasm function 28>
    1: 0x28fd0c5 - wit-component:shim!adapt-wasi_snapshot_preview1-fd_write
    2: 0x1216612 - libcomponentize_py_runtime.so!wasi::lib_generated::fd_write::h16f1318d12ef7a07
    3: 0x1207310 - libcomponentize_py_runtime.so!std::io::Write::write_all::hcae5d5a17ded01cf
    4: 0x11ff50f - libcomponentize_py_runtime.so!std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h9b174c565bf11cf0 (.llvm.10071916962893096014)
    5: 0x11ff3c4 - libcomponentize_py_runtime.so!std::thread::current::try_with_current::hb3d871380377cf67
    6: 0x120d9e2 - libcomponentize_py_runtime.so!std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h6f239d02db0f481d
    7: 0x120c7aa - libcomponentize_py_runtime.so!std::panicking::default_hook::he8216edd979025aa
    8: 0x120e1d3 - libcomponentize_py_runtime.so!std::panicking::rust_panic_with_hook::h02d894de16d94192
    9: 0x11f9d92 - libcomponentize_py_runtime.so!std::panicking::begin_panic_handler::_$u7b$$u7b$closure$u7d$$u7d$::he125d401eefa4f33
   10: 0x11f9cf3 - libcomponentize_py_runtime.so!std::sys::backtrace::__rust_end_short_backtrace::h31a9416a2c4ea1cb
   11: 0x120db45 - libcomponentize_py_runtime.so!__rustc::rust_begin_unwind
   12: 0x122f16e - libcomponentize_py_runtime.so!core::panicking::panic_fmt::h52dbee1629029330
   13: 0x124e734 - libcomponentize_py_runtime.so!core::result::unwrap_failed::h68b1db2abd074508
   14: 0x1186bf0 - libcomponentize_py_runtime.so!componentize-py#ToCanonString
   15: 0x28e15c9 - libcomponentize_py_bindings.so!fastly:api/http-resp#header-append-import
   16: 0x28e56d7 - libcomponentize_py_bindings.so!componentize-py#CallIndirect
   17:  0x185f3 - <unknown>!<wasm function 484>
   18: 0x118acc4 - libcomponentize_py_runtime.so!componentize_py_runtime::_$LT$impl$u20$componentize_py_runtime..call_import..MakeDef$GT$::_PYO3_DEF::trampoline::h88da0896868f0eed
   19: 0x1417d72 - cfunction_vectorcall_FASTCALL_KEYWORDS
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/methodobject.c:438:24
   20: 0x13bb483 - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11
                - PyObject_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:325:12
   21: 0x14dbd2d - _PyEval_EvalFrameDefault
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/Python/bytecodes.c:2706:19
   22: 0x14ddfd4 - _PyEval_EvalFrame
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_ceval.h:89:16
                - _PyEval_Vector
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/ceval.c:1683:12
   23: 0x13bb94d - _PyFunction_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c
   24: 0x13babcb - _PyObject_FastCallDictTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:133:15
   25: 0x13bbc35 - _PyObject_Call_Prepend
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:508:24
   26: 0x143d0c9 - slot_tp_call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/typeobject.c:8769:15
   27: 0x13baac3 - _PyObject_MakeTpCall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:240:18
   28: 0x13bb46e - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:90:16
                - PyObject_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:325:12
   29: 0x14dbd2d - _PyEval_EvalFrameDefault
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/Python/bytecodes.c:2706:19
   30: 0x14ddfd4 - _PyEval_EvalFrame
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_ceval.h:89:16
                - _PyEval_Vector
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/ceval.c:1683:12
   31: 0x13bb94d - _PyFunction_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c
   32: 0x13bdf7a - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11
                - method_vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/classobject.c:91:18
   33: 0x13bb30c - _PyVectorcall_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:271:16
   34: 0x13bb6ef - _PyObject_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:354:16
   35: 0x13bb789 - PyObject_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:379:12
   36:  0x181c9 - <unknown>!<wasm function 406>
   37: 0x118b45c - libcomponentize_py_runtime.so!pyo3::call::PyCallArgs::call_method_positional::hf0c9fd3e2a3bd359 (.llvm.11185300699313483585)
   38: 0x11857ab - libcomponentize_py_runtime.so!componentize-py#Dispatch
   39: 0x28e5648 - libcomponentize_py_bindings.so!fastly:api/reactor#serve-export

Caused by:
    wasm trap: wasm `unreachable` instruction executed
2025-08-29T16:46:00.922327Z ERROR There was an error handling the request error while executing at wasm backtrace:
    0: 0x1143b98 - wit-component:adapter:wasi_snapshot_preview1!<wasm function 28>
    1: 0x28fd0c5 - wit-component:shim!adapt-wasi_snapshot_preview1-fd_write
    2: 0x1216612 - libcomponentize_py_runtime.so!wasi::lib_generated::fd_write::h16f1318d12ef7a07
    3: 0x1207310 - libcomponentize_py_runtime.so!std::io::Write::write_all::hcae5d5a17ded01cf
    4: 0x11ff50f - libcomponentize_py_runtime.so!std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h9b174c565bf11cf0 (.llvm.10071916962893096014)
    5: 0x11ff3c4 - libcomponentize_py_runtime.so!std::thread::current::try_with_current::hb3d871380377cf67
    6: 0x120d9e2 - libcomponentize_py_runtime.so!std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h6f239d02db0f481d
    7: 0x120c7aa - libcomponentize_py_runtime.so!std::panicking::default_hook::he8216edd979025aa
    8: 0x120e1d3 - libcomponentize_py_runtime.so!std::panicking::rust_panic_with_hook::h02d894de16d94192
    9: 0x11f9d92 - libcomponentize_py_runtime.so!std::panicking::begin_panic_handler::_$u7b$$u7b$closure$u7d$$u7d$::he125d401eefa4f33
   10: 0x11f9cf3 - libcomponentize_py_runtime.so!std::sys::backtrace::__rust_end_short_backtrace::h31a9416a2c4ea1cb
   11: 0x120db45 - libcomponentize_py_runtime.so!__rustc::rust_begin_unwind
   12: 0x122f16e - libcomponentize_py_runtime.so!core::panicking::panic_fmt::h52dbee1629029330
   13: 0x124e734 - libcomponentize_py_runtime.so!core::result::unwrap_failed::h68b1db2abd074508
   14: 0x1186bf0 - libcomponentize_py_runtime.so!componentize-py#ToCanonString
   15: 0x28e15c9 - libcomponentize_py_bindings.so!fastly:api/http-resp#header-append-import
   16: 0x28e56d7 - libcomponentize_py_bindings.so!componentize-py#CallIndirect
   17:  0x185f3 - <unknown>!<wasm function 484>
   18: 0x118acc4 - libcomponentize_py_runtime.so!componentize_py_runtime::_$LT$impl$u20$componentize_py_runtime..call_import..MakeDef$GT$::_PYO3_DEF::trampoline::h88da0896868f0eed
   19: 0x1417d72 - cfunction_vectorcall_FASTCALL_KEYWORDS
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/methodobject.c:438:24
   20: 0x13bb483 - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11
                - PyObject_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:325:12
   21: 0x14dbd2d - _PyEval_EvalFrameDefault
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/Python/bytecodes.c:2706:19
   22: 0x14ddfd4 - _PyEval_EvalFrame
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_ceval.h:89:16
                - _PyEval_Vector
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/ceval.c:1683:12
   23: 0x13bb94d - _PyFunction_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c
   24: 0x13babcb - _PyObject_FastCallDictTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:133:15
   25: 0x13bbc35 - _PyObject_Call_Prepend
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:508:24
   26: 0x143d0c9 - slot_tp_call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/typeobject.c:8769:15
   27: 0x13baac3 - _PyObject_MakeTpCall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:240:18
   28: 0x13bb46e - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:90:16
                - PyObject_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:325:12
   29: 0x14dbd2d - _PyEval_EvalFrameDefault
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/Python/bytecodes.c:2706:19
   30: 0x14ddfd4 - _PyEval_EvalFrame
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_ceval.h:89:16
                - _PyEval_Vector
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Python/ceval.c:1683:12
   31: 0x13bb94d - _PyFunction_Vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c
   32: 0x13bdf7a - _PyObject_VectorcallTstate
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Include/internal/pycore_call.h:92:11
                - method_vectorcall
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/classobject.c:91:18
   33: 0x13bb30c - _PyVectorcall_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:271:16
   34: 0x13bb6ef - _PyObject_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:354:16
   35: 0x13bb789 - PyObject_Call
                    at /home/runner/work/componentize-py/componentize-py/cpython/builddir/wasi/../../Objects/call.c:379:12
   36:  0x181c9 - <unknown>!<wasm function 406>
   37: 0x118b45c - libcomponentize_py_runtime.so!pyo3::call::PyCallArgs::call_method_positional::hf0c9fd3e2a3bd359 (.llvm.11185300699313483585)
   38: 0x11857ab - libcomponentize_py_runtime.so!componentize-py#Dispatch
   39: 0x28e5648 - libcomponentize_py_bindings.so!fastly:api/reactor#serve-export

I commented out chunks of app.py to reduce it, finally narrowing it down to send_downstream(). You can construct params to send_downstream() just fine, but actually calling it crashes. Perhaps it now calls fd_write() where it didn't before. Putting this aside for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions