-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
const dummy = new ArrayBuffer(); RangeError at v8.js #31370
Comments
@developsessions I could not reproduce the issue, do you have a code example I could use here? |
@vdeturckheim: It crashes in my environment if I execute "const dummy = new ArrayBuffer();". |
@developsessions can you give me the output of |
@vdeturckheim of course, the output is:
|
That's very weird, I don't have a linux machine ready atm sadly :/ |
If you want, I can upload a Image of the machine anywhere ... |
I just tried using this docker image https://hub.docker.com/r/advancedclimatesystems/docker-buildroot/ and could not repro the issue. If you can provide me with a docker image with your setup, it woull be perfect indeed. |
I don't know about docker. But I can send a disk image. You can write it to a usb stick (with rufus) and you can boot from that usb stick. (Also in a virtual machine) |
@developsessions if you can manage to make a virtuablox image then It would save me a lot of time :) |
What flags are you or pm2 passing to node? Can you paste the output of |
Output: |
This seems irreproducible. I'm afraid I don't have good suggestions on how to proceed. Can you reproduce when you run just |
I have the same problem in my Raspberry Pi.
Some clues: as @developsessions, I am using buildroot, which means that the node version I use has been cross-compiled. My compilation host is a x64 running Gentoo where another node version is installed. |
Can someone (@vdeturckheim, @bnoordhuis) please point me to the source file where ArrayBuffer constructor is defined? I had a look in the source but could not find it. I suspect a |
@sveyret It’s here: node/deps/v8/src/builtins/builtins-arraybuffer.cc Lines 29 to 94 in e18afe4
I’m curious whether this is potentially a compiler bug? Could that be? You should be able to add |
@sveyret The code sections you're interested in are probably around: node/deps/v8/src/builtins/builtins-arraybuffer.cc Lines 48 to 53 in e18afe4
And: node/deps/v8/src/builtins/builtins-arraybuffer.cc Lines 87 to 90 in e18afe4
Note the |
@vdeturckheim That file contains the definitions for the C++ class behind |
Thanks @addaleax ! Very clear! |
@addaleax, yes, this could be a (cross-)compiler bug. Just for information, mine is:
|
I found something suspicious. I will make some tests but it may not be the cause of our problem. Anyway, I wonder why we test the host architecture here: node/deps/v8/src/objects/js-array-buffer.h Lines 26 to 30 in e18afe4
Shouldn't it be: #if V8_TARGET_ARCH_32_BIT |
@sveyret Yes, that seems like a bug. It’s not fully obvious to me how it would cause the problem here, but I think trying to fix it that way is worth it. 👍 |
Indeed, it is not the source of the problem. Actually, I found that the provided value for |
@sveyret Does that mean that |
@addaleax, I don't have appropriate dev tools on my machine, so I use the universal debugger: And no, I actually did not test the return value of |
So, after reading documentation, it seems that My main problem now is that, to my understanding, it should always fail. So why is it working most of the time? @addaleax, if you can give me some explanations… |
@sveyret Okay, all of that makes a lot of sense… I’m surprised that it doesn’t always fail in that case, as you are. Fwiw, as far as I can tell, when I run it on x64, is that (We call Just so we’re on the same page, you’re also on Node.js master? And the value passed to |
@addaleax, no, I'm not on master, but directly on 12.16.1. I need to make this version work, so I have to find a patch for it. If the bug is also on master, I'll create a PR. I'm not sure that the value is indeed a EDIT: I tested |
@sveyret If the bug exists on any of the supported Node.js release lines, a PR would be helpful, master or not. If you have a number that is a |
Some pointers:
|
@addaleax, for information, I made a few more tests just to be sure it is a compiler/glibc problem. I displayed the number value, its raw value (in hex - thank you @devsnek for the tip) and the result of The results are the same for all these 3 values: |
Ok, that’s unfortunately almost certainly a compiler bug then. We could probably work around this by just passing |
Yes, that's what I thought. I will try to generate my system using buildroot default toolchain, instead of my Gentoo cross-compiler to see if it's better. |
@addaleax, I made a few more tests, using other toolchains, and I always had the same problem. So I made a little program just to test the |
@sveyret This is a long shot, but any chance you can share the resulting |
@addaleax, you will find the binary file here: https://we.tl/t-zWCwZNnLRk |
Okay, my understanding of ARM assembly isn’t perfect, but here’s the interesting part:
(Before this are the This seems wrong to me, because it loosely corresponds to: if (x == 0) {
} else {
if (x < 0) x = ceil(x);
else x = floor(x);
}
return NewNumber(x); where the compiler appears to be under the assumption that So yeah, I think |
@addaleax, actually, I think that the assumption is that the NaN value does not exist, as if In my test binary, I simply wrote a small function: void analyze(double d, std::uint64_t &bits, int &tnan, int &teq) {
Visible v = { d };
bits = v.x;
tnan = std::isnan(d);
teq = d == d;
} When compiled normally, it creates: 8a4: e92d0830 push {r4, r5, fp}
8a8: e28db008 add fp, sp, #8
8ac: eeb40b40 vcmp.f64 d0, d0
8b0: e24dd00c sub sp, sp, #12
8b4: ed0b0b05 vstr d0, [fp, #-20] ; 0xffffffec
8b8: e14b41d4 ldrd r4, [fp, #-20] ; 0xffffffec
8bc: eef1fa10 vmrs APSR_nzcv, fpscr
8c0: 03a03001 moveq r3, #1
8c4: e1c040f0 strd r4, [r0]
8c8: 13a03000 movne r3, #0
8cc: 63a00001 movvs r0, #1
8d0: 73a00000 movvc r0, #0
8d4: e5810000 str r0, [r1]
8d8: e5823000 str r3, [r2]
8dc: e24bd008 sub sp, fp, #8
8e0: e8bd0830 pop {r4, r5, fp}
8e4: e12fff1e bx lr While if compiled with one of 8bc: e92d0830 push {r4, r5, fp}
8c0: e3a0c000 mov ip, #0
8c4: ec554b10 vmov r4, r5, d0
8c8: e28db008 add fp, sp, #8
8cc: e3a03001 mov r3, #1
8d0: e1c040f0 strd r4, [r0]
8d4: e581c000 str ip, [r1]
8d8: e5823000 str r3, [r2]
8dc: e24bd008 sub sp, fp, #8
8e0: e8bd0830 pop {r4, r5, fp}
8e4: e12fff1e bx lr Just as if NaN wouldn't exist… |
Correction, @addaleax! Actually, this is not the large file flags, but a EDIT: just to confirm that without the |
@developsessions, can you ensure that you did not select “optimize for fast” in Build options/gcc optimization level? The -Ofast makes the compiler being not compliant to standards, as it is indicated in the help of the choice. I open an issue for it is clearer that this choice is dangerous: https://bugs.busybox.net/show_bug.cgi?id=13046. |
@sveyret Thanks for looking further! Given that this is not something that Node.js or V8 can do anything about, I’ll close this issue as resolved 👍 |
Hi @ALL, ERROR: RangeError: Invalid array buffer length ENV: node -e 'console.log(process.versions)'{ |
In the file lib/v8.js there is a line "const dummy = new ArrayBuffer();".
In my node app started with pm2, I get the following error.
What is the purpose of this line and why ist there no argument in the constructor of ArrayBuffer?
/root/.pm2/logs/app-error.log last 15 lines:
0|app | v8.js:139
0|app | const dummy = new ArrayBuffer();
0|app | ^
0|app |
0|app | RangeError: Invalid array buffer length
0|app | at new ArrayBuffer ()
0|app | at v8.js:139:17
0|app | at NativeModule.compile (internal/bootstrap/loaders.js:364:7)
0|app | at Function.NativeModule.require (internal/bootstrap/loaders.js:176:18)
0|app | at Function.Module._load (internal/modules/cjs/loader.js:572:25)
0|app | at Module.require (internal/modules/cjs/loader.js:692:17)
0|app | at require (internal/modules/cjs/helpers.js:25:18)
0|app | at Object. (/usr/lib/node_modules/pm2/node_modules/@pm2/io/build/main/metrics/v8.js:3:12)
0|app | at Module._compile (internal/modules/cjs/loader.js:778:30)
0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
The text was updated successfully, but these errors were encountered: