From 8b1bc6112f43e707d007f8b82d6c8c50775c4328 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 29 Aug 2003 07:09:48 +0000 Subject: [PATCH] krshd hangs in linux nightly testing A typical stack trace: #0 0xffffe002 in ?? () #1 0x420da75f in syslog () from /lib/tls/libc.so.6 #2 0x0804ad06 in cleanup (signumber=15) at krshd.c:567 #3 #4 0xffffe000 in ?? () #5 0x4202774e in sigaction () from /lib/tls/libc.so.6 #6 0x0804ac82 in cleanup (signumber=1) at krshd.c:548 #7 #8 0xffffe002 in ?? () #9 0x4202774e in sigaction () from /lib/tls/libc.so.6 #10 0x420daa21 in vsyslog () from /lib/tls/libc.so.6 #11 0x420da75f in syslog () from /lib/tls/libc.so.6 #12 0x0804b670 in doit (f=3, fromp=0xbfffda50) at krshd.c:1313 #13 0x0804ab87 in main (argc=11, argv=0xbfffdb34) at krshd.c:459 #14 0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6 Yes, we're calling syslog from inside a signal handler. Yes, this is bad. And from some poking about that I did earlier, it appears that there's some locking code in vsyslog which may be deadlocking in the nested call. And this usually seems to happen when logging the "shell process completed" message. This is a quick patch to switch off the signal handlers before logging that message. I suspect the breakage happens earlier, though, so this might not fix the bug, just maybe move it around a little. * krshd.c (ignore_signals): Split out from cleanup(). (doit): Call it when the shell process has completed, before calling syslog. ticket: new status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15800 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 6 ++++++ src/appl/bsd/krshd.c | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 3a096e107..75066eedb 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,9 @@ +2003-08-29 Ken Raeburn + + * krshd.c (ignore_signals): Split out from cleanup(). + (doit): Call it when the shell process has completed, before + calling syslog. + 2003-05-23 Ken Raeburn * configure.in: Don't use libkrb524.a any more. diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index d625d8bd9..9fde43d6e 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -535,9 +535,8 @@ int auth_sys = 0; /* Which version of Kerberos used to authenticate */ #define KRB5_RECVAUTH_V4 4 #define KRB5_RECVAUTH_V5 5 -static krb5_sigtype -cleanup(signumber) - int signumber; +static void +ignore_signals() { #ifdef POSIX_SIGNALS struct sigaction sa; @@ -561,6 +560,13 @@ cleanup(signumber) killpg(pid, SIGTERM); #endif +} + +static krb5_sigtype +cleanup(signumber) + int signumber; +{ + ignore_signals(); wait(0); pty_logwtmp(ttyn,"",""); @@ -1302,13 +1308,14 @@ void doit(f, fromp) } else if (wcc != cc) { syslog(LOG_INFO, "only wrote %d/%d to child", wcc, cc); - } - } + } + } } } while ((port&&FD_ISSET(s, &readfrom)) || FD_ISSET(f, &readfrom) || (port&&FD_ISSET(pv[0], &readfrom) )|| FD_ISSET(pw[0], &readfrom)); + ignore_signals(); #ifdef KERBEROS syslog(LOG_INFO , "Shell process completed."); -- 2.26.2