Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in import tag #232

Open
ahuoguo opened this issue Nov 26, 2024 · 1 comment
Open

Bug in import tag #232

ahuoguo opened this issue Nov 26, 2024 · 1 comment

Comments

@ahuoguo
Copy link
Contributor

ahuoguo commented Nov 26, 2024

The following code

(module $a
  (tag $yield (export "yield") )
)
(register "a")

(module
  (type $task (func))
  (type $cont (cont $task))
  
  (import "spectest" "print_i32" (func $print_i32 (param i32)))
  (tag $yield (import "a" "yield"))

  (elem declare func $task)

  (func $task
    (suspend $yield)
  )

  (func $run (export "run")
    (block $h
        (block $on_yield (result (ref $cont))
          (resume $cont (on $yield $on_yield)
            (cont.new $cont (ref.func $task)))
          (call $print_i32 (i32.const 42))
          (br $h)
        )
        (drop)
        (call $print_i32 (i32.const 1))
    )
  )
)
(invoke "run")

Wizard seems to parse incorrect Module information when tag is imported. It successfully runs when I remove (import "a" "yield") in tag.

> wasm -d try.wast -o  try.bin.wast &&  spectest.jvm -ext:stack-switching try.bin.wast
##+try.bin.wast
##-fail: try.bin.wast @ 21:2 expected valid module, got invalid: overflow import section, expected 32 bytes, read 32

Context:

I was trying to run this stack switching wast file on wizard and I received the following error message:

> wasm -d control-lwt.wast -o  control-lwt.bin.wast &&  spectest.jvm -ext:stack-switching control-lwt.bin.wast
##+control-lwt.bin.wast
Exception in thread "main" java.lang.NullPointerException
        at V3C_SpecTestInterpreter.doInstantiate(Unknown Source)
        at V3C_SpecTestInterpreter.doModule(Unknown Source)
        at V3C_SpecTestInterpreter.doCommand(Unknown Source)
        at V3C_SpecTestInterpreter.run(Unknown Source)
        at V3K_spectest.runTest(Unknown Source)
        at V3K_spectest.main(Unknown Source)
        at V3K_spectest.main(Unknown Source)
@titzer
Copy link
Owner

titzer commented Nov 26, 2024

I looked into this and it seems like the stack-switching reference interpreter is not in agreement with the exception handling proposal's encoding of import/export tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants