-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
test: shared lib build doesn't handle SIGPIPE #19211
Conversation
@yhwang : can you please clarify - which one is embedded here: the parent or the child, or both?
|
This doesn't look correct to me. The signal should be handled by the binary because otherwise it's practically useless, the first aborted connection would kill it. |
The case here is both parent and child node executable are using shared lib. And the related code for signal handling is here: https://github.com/nodejs/node/blob/master/src/node.cc#L4103-L4117 and it's surrounded by For these two test cases, the parent create pipes for child's stdin, stdout and stderr. But after spawn, parent destroys the Because the case here is both parent and child are shared lib build, the child doesn't have signal handler registration (code in node.cc L110-L132 that I mentioned above), so the child directly exits when it writes to the I think there are 2 ways to fix this, one is to modify the test case like what I did in this change. And another one is to modify the node_main.cc to handle the signal if it's shared lib build ( |
I understand what you did and why but IMO it's papering over the real issue. This PR fixes the tests but it's only a matter of time before it reappears. I suggest moving some of the signal handling code from node.cc to node_main.cc. |
@bnoordhuis I agree with you totally. However, for now, the If you think |
I'd start out simple and move the |
@bnoordhuis sure! For double check,
I guess you were saying |
No, because both builds need it. If you move it, you can drop the corresponding code from node.cc that's currently guarded by a It's currently a loop that does this: if (nr == SIGKILL || nr == SIGSTOP) continue;
act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL;
CHECK_EQ(0, sigaction(nr, &act, nullptr)); And you could change that to: if (nr == SIGKILL || nr == SIGSTOP || nr == SIGPIPE) continue;
act.sa_handler = SIG_DFL;
CHECK_EQ(0, sigaction(nr, &act, nullptr)); But please leave a comment explaining why SIGPIPE can safely be skipped. I suppose a case could be made that much of |
I see. But only move SIGPIPE out of the I think only adding a section in node_main.cc would be more obvious and clear (because it would be surrounded by the And in the future, if the PlatformInit() could be moved to node_main.cc we won't need to put SIGPIPE back, right? Another approach is to suppress these 2 test cases for share lib build. |
24c5de4
to
c89b462
Compare
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: nodejs#18535 Signed-off-by: Yihong Wang <[email protected]>
c89b462
to
4a7be07
Compare
@bnoordhuis I reworked on the change and added a section in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for the review! |
smartos-15-64 failed with these logs:
But other smartos builds passed. I think the results are good. |
My understanding is that in SHLIB mode, absolutely no signal handling is carried out, and the responsibility is delegated to the embedder. Please confirm this. |
Yes, squashing signal handlers is only applied to non-shared lib build. Here is the commit: 0f0f3d3 . This PR modifies |
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: #18535 Signed-off-by: Yihong Wang <[email protected]> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Landed in ffd618b and closed this PR. |
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: #18535 Signed-off-by: Yihong Wang <[email protected]> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: #18535 Signed-off-by: Yihong Wang <[email protected]> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: nodejs#18535 Signed-off-by: Yihong Wang <[email protected]> PR-URL: nodejs#19211 Refs: nodejs#18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
For shared lib build, we leave the signal handling for embedding users. In these two test cases: - `parallel/test-process-external-stdio-close-spawn` - `parallel/test-process-external-stdio-close` The pipe is used for stdout and is destroied before child process uses it for logging. So the node executble that uses shared lib build receives SIGPIPE and the child process ends. This change ignores the SIGPIPE in node_main.cc for shared lib case. Refs: #18535 Signed-off-by: Yihong Wang <[email protected]> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Signed-off-by: Beth Griggs <[email protected]>
For shared lib build, we leave the signal handling for embedding users.
In these two test cases:
parallel/test-process-external-stdio-close-spawn
parallel/test-process-external-stdio-close
The pipe is used for stdout and is destroied before child process uses
it for logging. So the node executble that uses shared lib build
receives SIGPIPE and the child process ends. Need to modify these two
test cases to check the
SIGPIPE
instead.Refs: #18535
Signed-off-by: Yihong Wang [email protected]
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes