Stream: git-wasmtime

Topic: wasmtime / issue #8657 `ref.func`: undeclared function re...


view this post on Zulip Wasmtime GitHub notifications bot (May 20 2024 at 13:31):

oovm added the bug label to Issue #8657.

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2024 at 13:31):

oovm opened issue #8657:

Test Case

(component $App
    (core module $Main
        (type $i32-i32 (func (param i32) (result i32)))

        (func $hof (param $f (ref $i32-i32)) (result i32)
            (i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
        )

        (func $inc (param $i i32) (result i32)
            (i32.add (local.get $i) (i32.const 1))
        )

        (func $caller (result i32)
            (call $hof (ref.func $inc))
        )
    )
)

Steps to Reproduce

Expected Results

No error reported

Actual Results

Error: WebAssembly translation error

Caused by:
    Invalid input WebAssembly code at offset 67: undeclared function reference

Stack backtrace:
   0: std::backtrace_rs::backtrace::dbghelp::trace
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:131
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2: std::backtrace::Backtrace::create
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:331
   3: std::backtrace::Backtrace::capture
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:296
   4: anyhow::error::impl$1::from<enum2$<wasmtime_environ::compile::CompileError> >
             at .cargo\anyhow-1.0.85\src\error.rs:565
   5: core::result::impl$27::from_residual<wasmtime::compile::CompileOutput,enum2$<wasmtime_environ::compile::CompileError>,anyhow::Error>
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\result.rs:1963
   6: wasmtime::compile::impl$4::collect_inputs_in_translations::closure$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::ModuleTranslation>,wasmtime::compile::build_co
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:457
   7: core::ops::function::FnOnce::call_once<wasmtime::compile::impl$4::collect_inputs_in_translations::closure_env$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::Mod
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:250
   8: alloc::boxed::impl$47::call_once<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutpu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\boxed.rs:2016
   9: wasmtime::compile::impl$4::compile::closure$0
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:537
  10: wasmtime::engine::impl$1::run_maybe_parallel::closure$0<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error>
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\engine.rs:164
  11: core::ops::function::impls::impl$1::call_mut<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:272
  12: core::ops::function::impls::impl$4::call_once<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:305
  13: enum2$<core::option::Option<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marker::Send>,al
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\option.rs:1072
  14: core::iter::adapters::map::impl$2::next<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  15: core::iter::adapters::map::impl$2::next<enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Co
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  16: core::iter::adapters::take_while::impl$2::next<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\take_while.rs:47
  17: core::iter::adapters::map::impl$2::next<wasmtime::compile::CompileOutput,core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  18: alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>::extend_desugared<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2930
  19: alloc::vec::spec_extend::impl$0::spec_extend<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\spec_extend.rs:17
  20: alloc::vec::impl$18::extend<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed:
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2904
  21: rayon::iter::extend::impl$2::consume_iter<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dy
             at .cargo\rayon-1.10.0\src\iter\extend.rs:130
  22: rayon::iter::while_some::impl$4::consume_iter<wasmtime::compile::CompileOutput,rayon::iter::extend::ListVecFolder<wasmtime::compile::CompileOutput>,core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$
             at .cargo\rayon-1.10.0\src\iter\while_some.rs:139
  23: rayon::iter::map::impl$8::consume_iter<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,rayon::iter::while_some::WhileSomeFolder<rayon::iter::extend::ListVecFolde
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  24: rayon::iter::map::impl$8::consume_iter<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marke
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  25: rayon::iter::plumbing::Producer::fold_with<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,an
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:109
  26: rayon::iter::plumbing::bridge_producer_consumer::helper<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::Com
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:437
  27: rayon::iter::plumbing::bridge_producer_consumer::helper::closure$1<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::c
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:426
  28: rayon_core::join::join_context::call_b::closure$0<alloc::collections::linked_list::LinkedList<alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>,alloc::alloc::Global>,rayon::iter::plumbing::bridge_producer_consumer::helper::closure_env

[message truncated]

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2024 at 13:39):

oovm edited issue #8657:

Test Case

(component $App
    (core module $Main
        (type $i32-i32 (func (param i32) (result i32)))

        (func $hof (param $f (ref $i32-i32)) (result i32)
            (i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
        )

        (func $inc (param $i i32) (result i32)
            (i32.add (local.get $i) (i32.const 1))
        )

        (func $caller (result i32)
            (call $hof (ref.func $inc))
        )
    )
)

Steps to Reproduce

Expected Results

No error reported

Actual Results

Error: WebAssembly translation error

Caused by:
    Invalid input WebAssembly code at offset 67: undeclared function reference

Stack backtrace:
   0: std::backtrace_rs::backtrace::dbghelp::trace
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:131
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2: std::backtrace::Backtrace::create
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:331
   3: std::backtrace::Backtrace::capture
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:296
   4: anyhow::error::impl$1::from<enum2$<wasmtime_environ::compile::CompileError> >
             at .cargo\anyhow-1.0.85\src\error.rs:565
   5: core::result::impl$27::from_residual<wasmtime::compile::CompileOutput,enum2$<wasmtime_environ::compile::CompileError>,anyhow::Error>
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\result.rs:1963
   6: wasmtime::compile::impl$4::collect_inputs_in_translations::closure$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::ModuleTranslation>,wasmtime::compile::build_co
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:457
   7: core::ops::function::FnOnce::call_once<wasmtime::compile::impl$4::collect_inputs_in_translations::closure_env$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::Mod
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:250
   8: alloc::boxed::impl$47::call_once<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutpu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\boxed.rs:2016
   9: wasmtime::compile::impl$4::compile::closure$0
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:537
  10: wasmtime::engine::impl$1::run_maybe_parallel::closure$0<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error>
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\engine.rs:164
  11: core::ops::function::impls::impl$1::call_mut<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:272
  12: core::ops::function::impls::impl$4::call_once<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:305
  13: enum2$<core::option::Option<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marker::Send>,al
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\option.rs:1072
  14: core::iter::adapters::map::impl$2::next<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  15: core::iter::adapters::map::impl$2::next<enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Co
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  16: core::iter::adapters::take_while::impl$2::next<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\take_while.rs:47
  17: core::iter::adapters::map::impl$2::next<wasmtime::compile::CompileOutput,core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  18: alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>::extend_desugared<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2930
  19: alloc::vec::spec_extend::impl$0::spec_extend<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\spec_extend.rs:17
  20: alloc::vec::impl$18::extend<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed:
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2904
  21: rayon::iter::extend::impl$2::consume_iter<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dy
             at .cargo\rayon-1.10.0\src\iter\extend.rs:130
  22: rayon::iter::while_some::impl$4::consume_iter<wasmtime::compile::CompileOutput,rayon::iter::extend::ListVecFolder<wasmtime::compile::CompileOutput>,core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$
             at .cargo\rayon-1.10.0\src\iter\while_some.rs:139
  23: rayon::iter::map::impl$8::consume_iter<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,rayon::iter::while_some::WhileSomeFolder<rayon::iter::extend::ListVecFolde
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  24: rayon::iter::map::impl$8::consume_iter<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marke
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  25: rayon::iter::plumbing::Producer::fold_with<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,an
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:109
  26: rayon::iter::plumbing::bridge_producer_consumer::helper<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::Com
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:437
  27: rayon::iter::plumbing::bridge_producer_consumer::helper::closure$1<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::c
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:426
  28: rayon_core::join::join_context::call_b::closure$0<alloc::collections::linked_list::LinkedList<alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>,alloc::alloc::Global>,rayon::iter::plumbing::bridge_producer_consumer::helper::closure_env

[message truncated]

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2024 at 14:34):

alexcrichton commented on issue #8657:

Thanks for the report! The example you're copying in the function-references proposal, and the snippet here, are both invalid and need to be updated (at least in the function-references proposal). The validation of ref.func requires that the referenced function is already registered in an elem segment or defined global. For this you'll want to do something like:

(elem declare funcref (ref.func $inc))

where the complete example is:

(component $App
    (core module $Main
        (type $i32-i32 (func (param i32) (result i32)))

        (elem declare funcref (ref.func $inc)) ;; <- this line was added

        (func $hof (param $f (ref $i32-i32)) (result i32)
            (i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
        )

        (func $inc (param $i i32) (result i32)
            (i32.add (local.get $i) (i32.const 1))
        )

        (func $caller (result i32)
            (call $hof (ref.func $inc))
        )
    )
)

view this post on Zulip Wasmtime GitHub notifications bot (May 20 2024 at 15:28):

oovm closed issue #8657:

Test Case

(component $App
    (core module $Main
        (type $i32-i32 (func (param i32) (result i32)))

        (func $hof (param $f (ref $i32-i32)) (result i32)
            (i32.add (i32.const 10) (call_ref $i32-i32 (i32.const 42) (local.get $f)))
        )

        (func $inc (param $i i32) (result i32)
            (i32.add (local.get $i) (i32.const 1))
        )

        (func $caller (result i32)
            (call $hof (ref.func $inc))
        )
    )
)

Steps to Reproduce

Expected Results

No error reported

Actual Results

Error: WebAssembly translation error

Caused by:
    Invalid input WebAssembly code at offset 67: undeclared function reference

Stack backtrace:
   0: std::backtrace_rs::backtrace::dbghelp::trace
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:131
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2: std::backtrace::Backtrace::create
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:331
   3: std::backtrace::Backtrace::capture
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c/library\std\src\backtrace.rs:296
   4: anyhow::error::impl$1::from<enum2$<wasmtime_environ::compile::CompileError> >
             at .cargo\anyhow-1.0.85\src\error.rs:565
   5: core::result::impl$27::from_residual<wasmtime::compile::CompileOutput,enum2$<wasmtime_environ::compile::CompileError>,anyhow::Error>
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\result.rs:1963
   6: wasmtime::compile::impl$4::collect_inputs_in_translations::closure$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::ModuleTranslation>,wasmtime::compile::build_co
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:457
   7: core::ops::function::FnOnce::call_once<wasmtime::compile::impl$4::collect_inputs_in_translations::closure_env$0<core::iter::adapters::map::Map<cranelift_entity::iter::IterMut<wasmtime_types::StaticModuleIndex,wasmtime_environ::compile::module_environ::Mod
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:250
   8: alloc::boxed::impl$47::call_once<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutpu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\boxed.rs:2016
   9: wasmtime::compile::impl$4::compile::closure$0
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\compile.rs:537
  10: wasmtime::engine::impl$1::run_maybe_parallel::closure$0<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error>
             at C:\Users\Dell\.cargo\git\checkouts\wasmtime-41807828cb3a7a7e\a77e877\crates\wasmtime\src\engine.rs:164
  11: core::ops::function::impls::impl$1::call_mut<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:272
  12: core::ops::function::impls::impl$4::call_once<tuple$<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > >
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\ops\function.rs:305
  13: enum2$<core::option::Option<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marker::Send>,al
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\option.rs:1072
  14: core::iter::adapters::map::impl$2::next<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  15: core::iter::adapters::map::impl$2::next<enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Co
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  16: core::iter::adapters::take_while::impl$2::next<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\take_while.rs:47
  17: core::iter::adapters::map::impl$2::next<wasmtime::compile::CompileOutput,core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tu
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\core\src\iter\adapters\map.rs:108
  18: alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>::extend_desugared<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2930
  19: alloc::vec::spec_extend::impl$0::spec_extend<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\spec_extend.rs:17
  20: alloc::vec::impl$18::extend<wasmtime::compile::CompileOutput,alloc::alloc::Global,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed:
             at /rustc/6672c16afcd4db8acdf08a6984fd4107bf07632c\library\alloc\src\vec\mod.rs:2904
  21: rayon::iter::extend::impl$2::consume_iter<wasmtime::compile::CompileOutput,core::iter::adapters::map::Map<core::iter::adapters::take_while::TakeWhile<core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dy
             at .cargo\rayon-1.10.0\src\iter\extend.rs:130
  22: rayon::iter::while_some::impl$4::consume_iter<wasmtime::compile::CompileOutput,rayon::iter::extend::ListVecFolder<wasmtime::compile::CompileOutput>,core::iter::adapters::map::Map<core::iter::adapters::map::Map<rayon::vec::SliceDrain<alloc::boxed::Box<dyn$
             at .cargo\rayon-1.10.0\src\iter\while_some.rs:139
  23: rayon::iter::map::impl$8::consume_iter<enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> >,enum2$<core::option::Option<wasmtime::compile::CompileOutput> >,rayon::iter::while_some::WhileSomeFolder<rayon::iter::extend::ListVecFolde
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  24: rayon::iter::map::impl$8::consume_iter<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,anyhow::Error> > > >,core::marke
             at .cargo\rayon-1.10.0\src\iter\map.rs:248
  25: rayon::iter::plumbing::Producer::fold_with<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::CompileOutput,an
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:109
  26: rayon::iter::plumbing::bridge_producer_consumer::helper<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::compile::Com
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:437
  27: rayon::iter::plumbing::bridge_producer_consumer::helper::closure$1<rayon::vec::DrainProducer<alloc::boxed::Box<dyn$<core::ops::function::FnOnce<tuple$<ref$<dyn$<wasmtime_environ::compile::Compiler> > >,assoc$<Output,enum2$<core::result::Result<wasmtime::c
             at .cargo\rayon-1.10.0\src\iter\plumbing\mod.rs:426
  28: rayon_core::join::join_context::call_b::closure$0<alloc::collections::linked_list::LinkedList<alloc::vec::Vec<wasmtime::compile::CompileOutput,alloc::alloc::Global>,alloc::alloc::Global>,rayon::iter::plumbing::bridge_producer_consumer::helper::closure_env

[message truncated]


Last updated: Nov 22 2024 at 17:03 UTC