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

Invalid NodeJS behavior on system with AMD CPU #33503

Closed
damanis opened this issue May 21, 2020 · 11 comments
Closed

Invalid NodeJS behavior on system with AMD CPU #33503

damanis opened this issue May 21, 2020 · 11 comments

Comments

@damanis
Copy link

damanis commented May 21, 2020

Version: v12.16.1 (installed via nave)
Platform: Linux ubuntu 4.4.0-142-generic #168-Ubuntu SMP Wed Jan 16 21:00:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Subsystem:
vendor_id: AuthenticAMD
cpu family: 6
model: 6
model name: QEMU Virtual CPU version 2.5+
stepping : 3
cpu MHz: 2599.922
address sizes: 40 bits physical, 48 bits virtual
cpu cores : 4

What steps will reproduce the bug?

root@ubuntu:~# node -e 'var a; a|=0; console.log(a)'

What is the expected behavior?

The command should return '0'

What do you see instead?

The command returns '-1'

How often does it reproduce? Is there a required condition?

Always

Additional information

The command 'npm install <any_pkg_name>' output:
buffer.js:593
slice: (buf, start, end) => buf.utf8Slice(start, end),
^
RangeError: Index out of range
at Object.slice (buffer.js:593:37)
at Buffer.toString (buffer.js:790:14)
at Object.readFileSync (fs.js:403:41)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:22)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'ERR_OUT_OF_RANGE'

@mscdex
Copy link
Contributor

mscdex commented May 21, 2020

Have you checked to see if it's a problem with nave by trying to install the same version of node using one of the binary tarballs from nodejs.org directly or via your package manager (either via a nodesource repo or distro repo)?

@damanis
Copy link
Author

damanis commented May 23, 2020 via email

@damanis
Copy link
Author

damanis commented May 23, 2020 via email

@bnoordhuis
Copy link
Member

Since you specifically mention AMD - you mean the problem doesn't arise when you configure qemu/kvm to emulate an Intel CPU? Do you also see the issue on real hardware?

FWIW, I have a Ryzen 5 and everything works okay.

@damanis
Copy link
Author

damanis commented May 23, 2020 via email

@mscdex
Copy link
Contributor

mscdex commented May 23, 2020

Out of curiosity, did you check with node v10.x and v14.x on the same VM to see if the problems exist with those as well?

@damanis
Copy link
Author

damanis commented May 24, 2020 via email

@damanis
Copy link
Author

damanis commented May 24, 2020 via email

@bnoordhuis
Copy link
Member

I'm 99.9% sure this is a qemu bug, not a node.js or V8 bug. Unless you have reason to believe otherwise, I suggest closing this out and taking it up with the qemu people.

@damanis
Copy link
Author

damanis commented May 26, 2020 via email

@bnoordhuis
Copy link
Member

Node.js generates x86_64 machine code at runtime and that's notoriously hard for qemu to track; other architectures have instructions to invalidate the icache but x86_64 doesn't. You're not the first to hit a bug and you probably won't be the last.

I'll close this but if you or anyone else has further info, please leave a comment. Thanks for the report.

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

3 participants