long.js icon indicating copy to clipboard operation
long.js copied to clipboard

WASM check causes Node 16.1+ crash on ARMv6

Open adriancable opened this issue 3 years ago • 3 comments

Node 16.1+ does not support WASM on ARMv6. Unfortunately rather than failing nice, this code causes node to exit with an error, which unnecessarily prevents any packages that depend on long from running on ARMv6 for Node 16.1+:

try {
  wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
    0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1$
  ])), {}).exports;
} catch (e) {
  // no wasm support :(
}

makes node crash with:

#
# Fatal error in , line 0
# Liftoff bailout should not happen. Cause: Armv6 not supported

#
#
#
#FailureMessage Object: 0xb49faf50
Trace/breakpoint trap (core dumped)

Possible workaround: if os.cpus().find(cpu => cpu.model.includes('ARMv6')) then skip the WASM check.

Cc: @ebaauw, @Supereg, @oznu

adriancable avatar Jan 04 '22 23:01 adriancable

Hmm, this looks pretty bad. Has this been reported to Node.js already / is there a response? Not sure that working around this in every package using Wasm is the right approach.

dcodeIO avatar Jan 05 '22 01:01 dcodeIO

@dcodeIO - yes, I have just filed an issue with node (https://github.com/nodejs/node/issues/41402). I hope this issue will be given airtime and resolved very quickly! Unfortunately realism suggests we should expect this may not happen, and even if it does, old node versions have a habit of staying around.

I agree that working around this in every package that uses WASM is tiresome, but long is very very broadly used (4M downloads/week on npm) and so if there is a good candidate package for the 'morally hazardous' option of working around this at the package level might be the right one in this case. Thoughts?

adriancable avatar Jan 05 '22 03:01 adriancable

Update: this looks like a V8 bug. I have filed a ticket for it: https://bugs.chromium.org/p/v8/issues/detail?id=12527

adriancable avatar Jan 06 '22 00:01 adriancable