Copilot commented on code in PR #13296:
URL: https://github.com/apache/trafficserver/pull/13296#discussion_r3433011506
##########
src/traffic_crashlog/traffic_crashlog.cc:
##########
@@ -213,12 +212,14 @@ main(int /* argc ATS_UNUSED */, const char **argv)
if (wait_mode) {
EnableDeathSignal(SIGCONT);
kill(getpid(), SIGSTOP);
- }
- // If our parent changed, then we were woken after traffic_server exited.
There's no point trying to
- // emit a crashlog because traffic_server is gone.
- if (getppid() != parent) {
- return 0;
+ // A real crash sends us a notification on this socket; any other parent
exit just closes
+ // it, so EOF (or a short read) means there is nothing to log. getppid()
is unreliable here:
+ // PR_SET_PDEATHSIG can fire while our parent pid is still alive.
+ int crash_signo = 0; // unused; an int keeps the framing aligned with the
writer
+ if (read(STDIN_FILENO, &crash_signo, sizeof(crash_signo)) !=
sizeof(crash_signo)) {
+ return 0;
+ }
Review Comment:
`read()` on a SOCK_STREAM can return a short read or be interrupted (EINTR).
Treating anything other than an exact `sizeof(int)` as “no crash” can drop real
crash notifications if the read is partial/interrupted. Consider looping until
you either read the full int or hit EOF / a hard error.
##########
src/traffic_server/Crash.cc:
##########
@@ -146,6 +147,10 @@ crash_logger_init(const char *user)
crash_logger_pid = child;
crash_logger_fd = pipe[0];
+ // Don't leak this socket into later fork+exec children; the logger relies
on seeing EOF
+ // here when we (its parent) exit.
+ fcntl(crash_logger_fd, F_SETFD, FD_CLOEXEC);
Review Comment:
The `fcntl(..., F_SETFD, FD_CLOEXEC)` return value is ignored. If it fails,
the helper may block on shutdown because a fork+exec child inherited the
socket, and this regression will be hard to diagnose. Please check for errors
(and ideally preserve any existing FD flags).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]