-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Accidentally writing garbage to the IPC channel blows up parent in debug build #16491
Comments
IPC on Windows uses an ad hoc protocol that parent and child are expected to adhere to. So yes, working as intended as far as libuv is concerned. :-) There are a few (non-node.js) programs out there that speak libuv's protocol. Although unlikely, prohibiting stdio from being used as an IPC channel might break such programs. |
Assertion errors are acceptable when you violate an API contract in C, but not in Node.js. So Node.js should prevent this from happening. The following also reproduces the issue, so it's not limited to index.js const spawn = require('child_process').spawn
const path = require('path')
let dir = path.join(__dirname, 'child.js')
let server = spawn(process.argv0, [dir], {
stdio: [0, 1, 2, 'ipc']
}) child.js const fs = require('fs');
fs.writeSync(3, 'asdfasdfasdf'); Output:
My proposal:
|
IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. Fixes: nodejs#16491 Fixes: nodejs#17405
#17460 doesn't fix this issue. |
How about: #17545 ? I don't think we can disallow using IPC in the code. We would have to add a lot of asserts. This IPC is not reliable anyway, see my comment here: #17405 (comment). I say we document it is undefined. |
IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. PR-URL: #17460 Fixes: #16491 Fixes: #17405 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. PR-URL: #17460 Fixes: #16491 Fixes: #17405 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. PR-URL: #17460 Fixes: #16491 Fixes: #17405 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
IPC messages are more complicated than a simple pipe passing JSON objects separated by new line. This removes inaccurate notes about implementation from the documentation. PR-URL: #17460 Fixes: #16491 Fixes: #17405 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
I still believe that it shouldn't be possible to cause Node.js to crash so easily, and it's possible to prevent it (see my proposal in #16491 (comment)). But if the general opinion is that this is expected behavior, then I'm not going to oppose it. |
@seishun thanks. I'll mark as |
Given that there's been no further discussion here and no clear path forward, closing... but, I'm putting this on the futures project board so that it does not get lost. |
index.js
child.js
Outputs for 1,2,3 respectively:
At first I thought it's a bug in libuv, but now I'm not sure. From all the asserts, it seems it assumes the child will only write valid data. In that case, I think Node.js should either disallow using
console.log
whenstdout
is used for IPC, or disallow usingstdout
for IPC.The text was updated successfully, but these errors were encountered: