runtimeverification / runtimeverification/wasm-semantics

Error parsing a wat file generated by wasm2wat

Open
#288 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
WebAssembly
Stars
106
Forks
24
PR merge metrics
No merged PRs in 30d

Description

In the Polkadot Verification repo, we cannot parse a wat file (generated by wasm2wat) which contains the following line:

(module
  (elem (;0;) (i32.const 1) func
    $core::fmt::num::imp::<impl_core::fmt::Display_for_u32>::fmt::ha79246951b68fe80
    $core::fmt::ArgumentV1::show_usize::h9fa3e0fa2697756b
    $<&T_as_core::fmt::Debug>::fmt::hfb4e6e1c0fcf56c0
    $<&T_as_core::fmt::Display>::fmt::h16124ef9ce946986
    $<&T_as_core::fmt::Display>::fmt::h20cb1a1cf15c6d24
    $<core::ops::range::Range<Idx>_as_core::fmt::Debug>::fmt::hb35043a9877a7615
    $<char_as_core::fmt::Debug>::fmt::hef5da4a1a8a279fb
    $<&T_as_core::fmt::Debug>::fmt::h45f63439ed1bcf4b
    $<core::fmt::Arguments_as_core::fmt::Display>::fmt::hd1bbab0340bb1ec7
    $<&T_as_core::fmt::Debug>::fmt::hb97f009bf049e702
    $<&T_as_core::fmt::Debug>::fmt::hdad4d7f77d923220
    $<&T_as_core::fmt::Debug>::fmt::hed0921afd643a9ab
    $<&T_as_core::fmt::Display>::fmt::hd29f630af4e7d945
    $<&T_as_core::fmt::Display>::fmt::h94b083fea96f035d
    $core::ptr::real_drop_in_place::h0d888a1e0a723219
    $<&mut_W_as_core::fmt::Write>::write_str::h1dae3170eae7032e
    $<&mut_W_as_core::fmt::Write>::write_char::hf398abaebb576fef
    $<&mut_W_as_core::fmt::Write>::write_fmt::h432343c9b2aa3d72
    $core::ptr::real_drop_in_place::h087fbcfa01172045
    $<core::fmt::Error_as_core::fmt::Debug>::fmt::h6c3642b0f48bddb7
    $<T_as_core::any::Any>::type_id::h74b0a6610a938729
    $core::ptr::real_drop_in_place::h22b1e96983d394ed
    $<core::fmt::builders::PadAdapter_as_core::fmt::Write>::write_str::h98030c2343020556
    $core::fmt::Write::write_char::he833390620ea7010
    $core::fmt::Write::write_fmt::h26414c5889f666af
    $<&mut_W_as_core::fmt::Write>::write_str::hb15e49880ddc044c
    $<&mut_W_as_core::fmt::Write>::write_char::h75b4860908a7f781
    $<&mut_W_as_core::fmt::Write>::write_fmt::h35f1bf288aae94bb
    $<frame_system::__GetByteStructExtrinsicCount<T>_as_frame_metadata::DefaultByte>::default_byte::h590b0db3c6b449ba
    $<frame_system::__GetByteStructExtrinsicData<T>_as_frame_metadata::DefaultByte>::default_byte::h955b2c0f888864bb
    $<frame_system::__GetByteStructExtrinsicsRoot<T>_as_frame_metadata::DefaultByte>::default_byte::h84a73daae9722e2d
    $<pallet_randomness_collective_flip::__GetByteStructRandomMaterial<T>_as_frame_metadata::DefaultByte>::default_byte::h2d69d021efad6df4
    $<frame_system::__GetByteStructNumber<T>_as_frame_metadata::DefaultByte>::default_byte::hdbe11c8be83cd8fa
    $<pallet_grandpa::__GetByteStructCurrentSetId<T>_as_frame_metadata::DefaultByte>::default_byte::h6f36f28213563d08
    $<pallet_balances::__GetByteStructFreeBalance<T_I>_as_frame_metadata::DefaultByte>::default_byte::h2f66931a5ff7c359
    $<pallet_transaction_payment::Module<T>::module_constants_metadata::TransactionByteFeeDefaultByteGetter<T>_as_frame_metadata::DefaultByte>::default_byte::h583744c90a78d865
    $core::ptr::real_drop_in_place::h4591b5fec6163f10
    $<sp_inherents::Error_as_core::fmt::Debug>::fmt::ha5f9f2ebde354c3d
    $<&T_as_core::fmt::Debug>::fmt::h2d03750a236140d3
    $<pallet_timestamp::Module<T>::module_constants_metadata::MinimumPeriodDefaultByteGetter<T>_as_frame_metadata::DefaultByte>::default_byte::h4bda46306d59c7f1
    $<pallet_balances::Module<T_I>::module_constants_metadata::ExistentialDepositDefaultByteGetter<T_I>_as_frame_metadata::DefaultByte>::default_byte::h94dad39d726e3e64
    $<pallet_grandpa::__GetByteStructState<T>_as_frame_metadata::DefaultByte>::default_byte::hfbecc956d06bc09f
    $<&mut_W_as_core::fmt::Write>::write_str::hf44d9a42cc805d91
    $<&mut_W_as_core::fmt::Write>::write_char::haaefd731da91efbe
    $<&mut_W_as_core::fmt::Write>::write_fmt::h60f7f467d79e8814   $<pallet_sudo::__GetByteStructKey<T>_as_frame_metadata::DefaultByte>::default_byte::hdaa2bf19666c20c8
    $frame_system::Module<T>::storage_metadata::h4ab6418f064d6e14
    $frame_system::Module<T>::call_functions::h8249958767cf1850
    $node_template_runtime::Runtime::__module_events_system::h89aa519d5c3b0998
    $<node_template_runtime::template::Module<T>_as_frame_metadata::ModuleErrorMetadata>::metadata::h28b46e9e2aada3c0
    $<frame_system::Module<T>_as_frame_metadata::ModuleErrorMetadata>::metadata::he35b623a643e9f90
    $pallet_timestamp::Module<T>::storage_metadata::h164597403c936805
    $pallet_timestamp::Module<T>::call_functions::h62d5bce507a13864
    $pallet_timestamp::Module<T>::module_constants_metadata::hfac79a91a0b09a55
    $pallet_grandpa::Module<T>::storage_metadata::h0e4052f883015d1e
    $pallet_grandpa::Module<T>::call_functions::h760c3f8134a147f7
    $node_template_runtime::Runtime::__module_events_grandpa::hee11132fe69b9cfc
    $pallet_indices::Module<T>::storage_metadata::h622e96e100413146
    $node_template_runtime::Runtime::__module_events_indices::h7c1f26c2f6339ddd
    $pallet_balances::Module<T_I>::storage_metadata::h082815e2817e5c19
    $pallet_balances::Module<T_I>::call_functions::h5c8befb10787dea0
    $node_template_runtime::Runtime::__module_events_balances::h98ed251006d93322
    $pallet_balances::Module<T_I>::module_constants_metadata::h487a5f31fed8642e
    $pallet_transaction_payment::Module<T>::storage_metadata::h1355847cc5795baf
    $pallet_transaction_payment::Module<T>::module_constants_metadata::hac56e2f8b747714d
    $pallet_sudo::Module<T>::storage_metadata::hc16b6a8a1cd765e8
    $pallet_sudo::Module<T>::call_functions::hfee628faae0d77da
    $node_template_runtime::Runtime::__module_events_sudo::hd6e1c047a7a3b148
    $node_template_runtime::template::Module<T>::storage_metadata::h008b32b98f124856
    $node_template_runtime::template::Module<T>::call_functions::h9a003a4c8d619b97
    $node_template_runtime::Runtime::__module_events_template::hb10f562ca4c8e4d6
    $pallet_randomness_collective_flip::Module<T>::storage_metadata::h1f7aef9e98d5441e
  )
)

It seems that we must have some deficiency in our grammar if we can't parse something produced by wasm2wat.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by submitting the provided wasm2wat output to the repository's WAT parser, then inspect the grammar around the elem segment and function-name tokens. Done means this generated WAT snippet parses successfully without weakening support for existing syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.