Skip to content

ctor-eval crashes when a non-env imported memory is written to #8146

Description

@stevenfontanella

Similar to #8145, ctor-eval crashes when the ctor writes to an imported memory. We should throw FailToEvalException and stop evaluation instead of crashing.

Repro:

(module
 (import "import" "memory" (memory $memory 1 1))
 (func $foo (result i32)
  (i32.store (i32.const 1) (i32.const 1))
  (i32.const 1)
 )
 (export "foo" (func $foo))
) 
ninja && python3 check.py ctor-eval --filter='*imports*'
ninja: no work to do.

[ checking wasm-ctor-eval... ]

.. imports.wast
executing:  /usr/local/google/home/stevenfont/code/binaryen/bin/wasm-ctor-eval /usr/local/google/home/stevenfont/code/binaryen/test/ctor-eval/imports.wast -all -o a.wat -S --ctors foo
terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at
^C
Traceback (most recent call last):
  File "/usr/local/google/home/stevenfont/code/binaryen/check.py", line 436, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/local/google/home/stevenfont/code/binaryen/check.py", line 419, in main
    TEST_SUITES[test]()
    ~~~~~~~~~~~~~~~~~^^
  File "/usr/local/google/home/stevenfont/code/binaryen/check.py", line 121, in run_ctor_eval_tests
    support.run_command(cmd)
    ~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/google/home/stevenfont/code/binaryen/scripts/test/support.py", line 224, in run_command
    out, err, code = _subprocess_run(cmd, stdout=subprocess.PIPE, stderr=stderr, encoding='UTF-8')
                     ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/google/home/stevenfont/code/binaryen/scripts/test/support.py", line 201, in _subprocess_run
    proc = subprocess.run(*args, **kwargs)
  File "/usr/lib/python3.13/subprocess.py", line 556, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/subprocess.py", line 1209, in communicate
    stdout = self.stdout.read()
KeyboardInterrupt

Activity

  1. changed the title [-]ctor-eval crashes when an imported memory is written to[/-] [+]ctor-eval crashes when a non-env imported memory is written to[/+] on Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions