wasmerio/wasmer

Singlepass panics: ImpossibleRelocation

Closed this issue · 3 comments

Singlepass panic with an ImpossibleRelocation error when compiling the following packages:

  • dermagen/siof

    • 1.0.3 (issue on ARM)

      $ wasmer run dermagen/siof@1.0.3 --singlepass --entrypoint=siof
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called Result::unwrap() on an Err value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      $ wasmer compile atom_0.wasm -o atom_0.wasmu --singlepass --target "x86_64-unknown-linux-musl" -m avx  
      Compiler: singlepass
      Target: x86_64-unknown-linux-musl
      ✔ File compiled successfully to `atom_0.wasmu`.
    • 1.0.2 (issue only on ARM)

      $ wasmer run dermagen/siof@1.0.2 --singlepass --entrypoint=siof
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      $ wasmer compile atom_0.wasm -o atom_0.wasmu --singlepass --target "x86_64-unknown-linux-musl" -m avx 
      Compiler: singlepass
      Target: x86_64-unknown-linux-musl
      ✔ File compiled successfully to `atom_0.wasmu`.
  • pancake/r2 (issue only on ARM)

    • 5.6.2 (issue only on ARM)

      $ wasmer run pancake/r2@=5.6.2 --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      
      ```bash
      $ wasmer compile atom_0.wasm -o atom_0.wasmu --singlepass --target "x86_64-unknown-linux-musl" -m avx
      Compiler: singlepass
      Target: x86_64-unknown-linux-musl
      ✔ File compiled successfully to `atom_0.wasmu`.
    • 5.4.4 (issue only on ARM)

      $ wasmer run pancake/r2@=5.4.4 --singlepass -- -v
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
      $ wasmer compile atom_0.wasm -o atom_0.wasmu --singlepass --target "x86_64-unknown-linux-musl" -m avx 
      Compiler: singlepass
      Target: x86_64-unknown-linux-musl
      ✔ File compiled successfully to `atom_0.wasmu`.
    • 5.4.3

      $ wasmer run pancake/r2@=5.4.3 --singlepass
      error: The WEBC file doesn't contain any executable commands
  • pancake/rasm2

    • 5.6.2

      $ wasmer run pancake/rasm2@=5.6.2 --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • kassandra/kassandra-node

    • 0.1.1

      $ wasmer run kassandra/kassandra-node@=0.1.1  --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    • 0.1.0

      $ wasmer run kassandra/kassandra-node@=0.1.0  --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • nturley/yosys

    • 0.1.0

      $ wasmer run nturley/yosys@=0.1.0 --singlepass
      error: The WEBC file doesn't contain any executable commands
    • 0.1.1

    • 0.1.2

      $ wasmer run nturley/yosys@=0.1.2 --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • yehowshua/yosys

    • 0.9.2

      $ wasmer run yehowshua/yosys@=0.9.2 --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  • php/php

    • 0.1.1

      $ wasmer run php/php@=0.1.1 --singlepass
      thread '<unnamed>' panicked at lib/compiler-singlepass/src/machine_arm64.rs:2294:35:
      called `Result::unwrap()` on an `Err` value: ImpossibleRelocation(Dynamic(DynamicLabel(0)))
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Here are the packages that make singlepass panic, divided in 4 parts to make github happy.
wasms.zip
wasms_3.zip
wasms_4.zip
wasms_2.zip

I confirm that they all compile correctly on singlepass when targeting x86_64.

After an initial investigation, we found that the cause of the ImpossiblePanic(DynamicRelocation(0)) issue is the usage of dynamic labels that resolve to an offset larger than 19 bits. The related documentation, in fact, prescribes the offset to be 19 bits and 4-bytes aligned. In the emit_cbz_label function no check was done to respect this prescription - in fact, it seems reasonable that it is not that trivial, if feasible at all, to check which will be the finalised size of the relocation and change the generated code as a consequence.

#4559 resolves the panics in the modules contained in the zip files above generating code that respects this prescription. This involved creating a new function emit_cbz_label_far that finds a way around the 19 bits imposition. In order to avoid degrading performance in the general case, we tracked the functions that used emit_cbz_label and eventually generated the panic and changed those cases to use emit_cbz_label_far.

#4559 is now merged. Closing