-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
chunked piping to stdin causes node to crash #41151
Comments
Here's a repro using NodeJS alone with
Notice that if the program is altered to output the file in one chunk, it works correctly:
|
This is not a |
setImmediate
causes TypeError: callback is not a function
I'm not even sure it's chunked piping because I can get it to fail frequently (but not always--run it many times) with a pretty small input like this: var _calls_ = 0, a = 0, b = 10;
function f0(foo, bar) {
--b + (~((foo && (foo[--b + (foo && typeof foo.set == "function" && --_calls_ >= 0 && foo.set())] = (3 > 2 || 22) ^ Infinity + 0)) / (([] & [ , 0 ][1]) << (38..toString() == -2))));
}
f0([ ].__proto__, --b + ([ , a ] = []));
console.log('done'); Running that through var _calls_=0,a=0,b=10;function f0(foo,bar){--b+~((foo&&(foo[--b+(foo&&typeof foo.set=="function"&&--_calls_>=0&&foo.set())]=(3>2||22)^Infinity+0))/(([]&[,0][1])<<(38..toString()==-2)))}f0([].__proto__,--b+([,a]=[]));console.log("done"); |
(And I can create vastly larger output that doesn't cause a problem at all.) |
Removing @nodejs/console |
OK, I think the problem here is that the code mutates Array prototype, causing internal Node.js functions to throw. This is a good instance of what primordials and related topics are trying to prevent, but we're not sure we're going to do that for things like this or not. See nodejs/TSC#1104 for current conversation around these topics. I think we can close this as "working as expected--mutate the Array's prototype and weird stuff is going to happen". |
Here's what I've come up with as a minimal reproduction: [].__proto__[7] = 1;
console.log('done'); It only throws the error (most of the time) in a pipeline because |
@Trott thanks for narrowing the test case down − another thing to teach our fuzzer to overlook 👌 |
Version
v10.24.1 − v17.2.0
Platform
tested so far on macOS & Windows
Subsystem
No response
What steps will reproduce the bug?
test.js
Please refer to mishoo/UglifyJS#5217 (comment) for more details.
How often does it reproduce? Is there a required condition?
Readily reproducible, but note that if you simply do
cat test.js | node
it would not fail.What is the expected behavior?
No exceptions being thrown.
What do you see instead?
An exception is thrown.
Additional information
No response
The text was updated successfully, but these errors were encountered: