| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@yhwang : can you please clarify - which one is embedded here: the parent or the child, or both?
|
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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 #ifndef NODE_SHARED_MODE, which means shared lib users should handle that by their own. For these two test cases, the parent create pipes for child's stdin, stdout and stderr. But after spawn, parent destroys the stdout. And in the console.js, it catches the error and ignore it here: https://github.com/nodejs/node/blob/master/lib/console.js#L110-L132 . So, in regular build (not using shared lib), when the child tries to write to stdout in line 13: console.log('logging should not cause a crash'); it hits the SIGPIPE and handle it (actually, ignores it) then the child process exits with status code 0 and null for term_signal. 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 stdout. The exit code and term signal that parent receives are status code: 1 and term sign: SIGPIPE. 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 (#ifdef NODE_SHARED_MODE). Because I just borrow main() function from node_main.cc for the shared lib build, I don't think changing node_main.cc for this case is a good idea. So, I chose the first one :-). |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
@bnoordhuis I agree with you totally. However, for now, the node_main.cc is used to build the executable for shared lib temporally. We should have an example node_shared_main.cc for the embedding users and also provide some tips about how to build the shared lib, link the shared lib and what things they need to handle when using shared lib. If you think node_shared_main.cc is not necessary, I can refactor the signal handling code in node.cc as a public API and call it in node_main.cc for shared lib case. |
Sorry, something went wrong.
|
I'd start out simple and move the sigaction(SIGPIPE, ...) to node_main.cc, that fixes the immediate issue. |
Sorry, something went wrong.
|
@bnoordhuis sure! For double check,
I guess you were saying copy the sigaction(SIGPIPE,...) to node_main.cc with #ifdef NODE_SHARED_MODE, right? |
Sorry, something went wrong.
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 #ifndef NODE_SHARED_MODE. 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 PlatformInit() properly belongs in node_main.cc rather than node.cc but let's start small. |
Sorry, something went wrong.
|
I see. But only move SIGPIPE out of the #ifndef NODE_SHARED_MODE section seems not a good idea. In that case, it separates the PlatformInit() logic into two places and because of two test case hit the SIGPIPE in the shared lib build. Is it worthy? I think only adding a section in node_main.cc would be more obvious and clear (because it would be surrounded by the #ifdef NODE_SHARED_MODE. 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. |
Sorry, something went wrong.
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 <yh.wang@ibm.com>
|
@bnoordhuis I reworked on the change and added a section in node_main.cc to ignore SIGPIPE and put comment to explain about the change. Hope it's easier and clearer for the node::PlatformInit() move in the future. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
Thank you for the review! |
Sorry, something went wrong.
|
smartos-15-64 failed with these logs: FATAL: java.io.IOException: Connection reset by peer java.io.IOException: Connection reset by peer ......... no workspace for node-test-commit-smartos/nodes=smartos15-64 #15952 But other smartos builds passed. I think the results are good. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Yes, squashing signal handlers is only applied to non-shared lib build. Here is the commit: 0f0f3d3 . This PR modifies node_main.cc to handle SIGPIPE and is not related shared lib. (shared lib doesn't include node_main.cc) |
Sorry, something went wrong.
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 <yh.wang@ibm.com> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
|
Landed in ffd618b and closed this PR. |
Sorry, something went wrong.
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 <yh.wang@ibm.com> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <yh.wang@ibm.com> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <yh.wang@ibm.com> PR-URL: nodejs#19211 Refs: nodejs#18535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <yh.wang@ibm.com> PR-URL: #19211 Refs: #18535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
| Back | FazBrowse Home | New Git URL |
For shared lib build, we leave the signal handling for embedding users.
In these two test cases:
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 yh.wang@ibm.com
Checklist