ChainSafe / gossamer

🕸️ Go Implementation of the Polkadot Host
https://chainsafe.github.io/gossamer
GNU Lesser General Public License v3.0
427 stars 110 forks source link

bug(lib/runtime): nil pointer dereference while calling `env.ext_misc_print_hex_version_1(i64)` #4040

Closed EclesioMeloJunior closed 2 weeks ago

EclesioMeloJunior commented 2 weeks ago

Describe the bug

June 01, 2024 at 01:39 (UTC-4:00) | 2024-06-01T05:39:34Z ERROR requesting max blocks from best block header: while handling workers results: while handling ready block: processing block data with header and body: handling block: failed to execute block 11541517: running runtime function: runtime error: invalid memory address or nil pointer dereference (recovered by wazero)
-- | -- | -- | --
June 01, 2024 at 01:39 (UTC-4:00) | wasm stack trace:
June 01, 2024 at 01:39 (UTC-4:00) | env.ext_misc_print_hex_version_1(i64)

June 01, 2024 at 01:39 (UTC-4:00)
2024-06-01T05:39:34Z ERROR requesting max blocks from best block header: while handling workers results: while handling ready block: processing block data with header and body: handling block: failed to execute block 11541517: running runtime function: runtime error: invalid memory address or nil pointer dereference (recovered by wazero)
June 01, 2024 at 01:39 (UTC-4:00) wasm stack trace:
June 01, 2024 at 01:39 (UTC-4:00) env.ext_misc_print_hex_version_1(i64)
EclesioMeloJunior commented 2 weeks ago

After a quick investigation I discovered that some imported runtime functions were using WithGoFunction and the m api.Module parameter was receiving nil (strangely), so the fix should be: