Skip to content

wasm2c/spec/simd_address.txt fails on non-x86 #2240

Open

Description

@rathann

When running the test suite of wabt-1.0.33 on aarch64 on Fedora 38, I get this (new) test failure:

- test/wasm2c/spec/simd_address.txt
  expected error code 0, got 1.
  STDERR MISMATCH:
  --- expected
  +++ actual
  @@ -0,0 +1,11 @@
  +Traceback (most recent call last):
  +  File "/builddir/build/BUILD/wabt-1.0.33/test/run-spec-wasm2c.py", line 648, in <module>
  +    sys.exit(main(sys.argv[1:]))
  +             ^^^^^^^^^^^^^^^^^^
  +  File "/builddir/build/BUILD/wabt-1.0.33/test/run-spec-wasm2c.py", line 642, in main
  +    utils.Executable(main_exe, forward_stdout=True).RunWithArgs()
  +  File "/builddir/build/BUILD/wabt-1.0.33/test/utils.py", line 95, in RunWithArgs
  +    raise error
  +utils.Error: Error running "out/test/wasm2c/spec/simd_address/simd_address" (1):
  +None
  +out/test/wasm2c/spec/simd_address/simd_address-main.c:499: assertion failed: expected w2c_simd__address__1__wasm_v1280x2Eload_offset_65521(&simd__address__1__wasm_instance) to trap.
  STDOUT MISMATCH:
  --- expected
  +++ actual
  @@ -1 +1 @@
  -42/42 tests passed.
  +41/42 tests passed.

Activity

  1. keithw commented on May 25, 2023

    @keithw
    Member

    Thanks as always for these reports! I think this particular one is expected and "disclosed" here: https://github.com/WebAssembly/wabt/blob/main/src/template/wasm2c_simd.declarations.c#L6

    The root issue here is that:

    • out-of-bounds accesses on Wasm must trap deterministically, but
    • wasm2c tries to use the MMU to detect out-of-bounds accesses and raise a signal, but this kind of side-effect isn't something the compiler cares to preserve if the load can otherwise be optizmed out, so
    • wasm2c needs to force the C compiler not to optimize out a load, which is done with an empty inline asm statement that marks the result of the load as "read,"
    • but (unlike with a 32-bit or 64-bit register), there's no architecture-independent way to describe a 128-bit SIMD register, so at present we only have this for SIMD on x86.

    Would happily take a contribution of the appropriate asm for aarch64 (possibly "w" per https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html) if somebody is able to test and say it works... I do wish we had CI tests on aarch64 given the interest in this architecture.

  2. sbc100 commented on May 25, 2023

    @sbc100
    Member

    Should we update the TODO such that it will #warning or #error when building on unsupported arch?

    Also, I guess we should skip these tests on those platforms too..

  3. sbc100 commented on May 25, 2023

    @sbc100
    Member

    @rathann do you actually care about using the SIMD support in wasm2c on arm64 or are you just interested in getting the tests to pass?

  4. rathann commented on May 26, 2023

    @rathann
    ContributorAuthor

    Personally, it's the latter. We do have a growing interest in WebAssembly in Fedora, so others might actually be interested. I'll ask the other SIG members.

  5. changed the title [-]wasm2c/spec/simd_address.txt fails on aarch64[/-] [+]wasm2c/spec/simd_address.txt fails on non-x86[/+] on May 26, 2023
  6. rathann commented on May 26, 2023

    @rathann
    ContributorAuthor

    I see this on ppc64le and s390x, too.

  7. rathann commented on Feb 21, 2025

    @rathann
    ContributorAuthor

    Looks like this is fixed on s390x, now that I'm running the tests using cmake --target run-tests.

  8. SoniEx2 commented on Feb 21, 2025

    @SoniEx2
    Collaborator

    indeed, s390x doesn't use guard pages and falls back to range checking, while this issue only occurs with guard pages. #2545 would fix it everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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