[yast-commit] r65488 - in /branches/SuSE-SLE-10-SP4-Branch/core: ./ VERSION agent-system/src/ShellCommand.cc liby2/src/Y2ProgramComponent.cc liby2/src/genericfrontend.cc package/yast2-core.changes
Author: mvidner Date: Wed Aug 31 19:13:13 2011 New Revision: 65488 URL: http://svn.opensuse.org/viewcvs/yast?rev=65488&view=rev Log: Merged from SP3 SVN. Tested by the customer, it did not help the problem and in the end the bug was in glibc, BUT the patch does switch to thread safe functions and adds the backtrace, useful for future maintenance. Prevent YaST hanging when threads are used (bnc#708367), backport: - Log the C backtrace when receiving a signal (FATE#302167). - avoid y2log in both signal handler and forked children (bnc#493152) - Resurrected logging in the signal handler, into /var/log/YaST2/signal (or ./y2signal.log) (bnc#493152#c33). - /var/log/YaST2/signal: do not make it executable svn merge -c65234 http://svn.opensuse.org/svn/yast/branches/SuSE-SLE-10-SP3-Branch/core Modified: branches/SuSE-SLE-10-SP4-Branch/core/ (props changed) branches/SuSE-SLE-10-SP4-Branch/core/VERSION branches/SuSE-SLE-10-SP4-Branch/core/agent-system/src/ShellCommand.cc branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/Y2ProgramComponent.cc branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/genericfrontend.cc branches/SuSE-SLE-10-SP4-Branch/core/package/yast2-core.changes Modified: branches/SuSE-SLE-10-SP4-Branch/core/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP4-Branch/core/VERSION?rev=65488&r1=65487&r2=65488&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP4-Branch/core/VERSION (original) +++ branches/SuSE-SLE-10-SP4-Branch/core/VERSION Wed Aug 31 19:13:13 2011 @@ -1 +1 @@ -2.13.47 +2.13.48 Modified: branches/SuSE-SLE-10-SP4-Branch/core/agent-system/src/ShellCommand.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP4-Branch/core/agent-system/src/ShellCommand.cc?rev=65488&r1=65487&r2=65488&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP4-Branch/core/agent-system/src/ShellCommand.cc (original) +++ branches/SuSE-SLE-10-SP4-Branch/core/agent-system/src/ShellCommand.cc Wed Aug 31 19:13:13 2011 @@ -117,7 +117,7 @@ FILE *stream2 = fdopen (pipe2[0], "r"); if (stream2 == 0) { - y2error ("stream2 fdopen error"); + y2error ("stream2 fdopen error"); _exit (1); } close (pipe2[1]); @@ -126,7 +126,8 @@ { if (out) fputs (s2, out); - y2debug ("%s", s2); + //bnc#493152#c24 + //y2debug ("%s", s2); } fclose (stream2); @@ -154,7 +155,7 @@ else ret = WTERMSIG (ret) + 128; - y2debug ("Exit status is %d", ret); + //y2debug ("Exit status is %d", ret); if (!tempdir.empty ()) { Modified: branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/Y2ProgramComponent.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/Y2ProgramComponent.cc?rev=65488&r1=65487&r2=65488&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/Y2ProgramComponent.cc (original) +++ branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/Y2ProgramComponent.cc Wed Aug 31 19:13:13 2011 @@ -291,13 +291,14 @@ // Call chroot if desired. if (chroot_path == "" || chroot_path == "/") { - y2debug ("Going to execute %s", bin_file.c_str ()); + //bnc#493152#c24 + //y2debug ("Going to execute %s", bin_file.c_str ()); } else { - y2debug ("Going to execute %s with chroot %s", bin_file.c_str (), - chroot_path.c_str ()); + /*y2debug ("Going to execute %s with chroot %s", bin_file.c_str (), + chroot_path.c_str ());*/ if (chroot (chroot_path.c_str ()) != 0) { - y2error ("Cannot chroot to %s: %s", chroot_path.c_str (), - strerror (errno)); + /*y2error ("Cannot chroot to %s: %s", chroot_path.c_str (), + strerror (errno));*/ _exit (5); } @@ -307,7 +308,7 @@ execv (bin_file.c_str (), argv); // execute program // this code is only reached if exec failed - y2error ("Cannot execute external program %s", bin_file.c_str ()); + //y2error ("Cannot execute external program %s", bin_file.c_str ()); _exit (5); // No sense in returning! I am forked away!! } Modified: branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/genericfrontend.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/genericfrontend.cc?rev=65488&r1=65487&r2=65488&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/genericfrontend.cc (original) +++ branches/SuSE-SLE-10-SP4-Branch/core/liby2/src/genericfrontend.cc Wed Aug 31 19:13:13 2011 @@ -28,6 +28,10 @@ #include <stdarg.h> #include <unistd.h> #include <signal.h> +#include <execinfo.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> #include <sstream> #include <ycp/y2log.h> @@ -49,14 +53,119 @@ static void print_error (const char*, ...) __attribute__ ((format (printf, 1, 2))); static bool is_ycp_value (const char* arg); +int signal_log_fd; // fd to use for logging in signal handler + +static +void +signal_log_to_fd (int fd, const char * cs) +{ + ssize_t n = strlen (cs); + while (true) { + ssize_t w = write(fd, cs, n); + if (w == n) + break; // success + else if (w == -1) { + if (errno == EINTR) { + // perror("gotcha"); // bnc#470645 + } + else { + perror("write"); // other cases + break; + } + } + else { + errno = 0; + cs += w; + n -= w; + } + } + +} + +static +void +signal_log (const char * cs) +{ + signal_log_to_fd (signal_log_fd, cs); +} + +static +void +signal_log_timestamp () +{ + char buffer[200]; + time_t time_time; + struct tm tm_time; + + time_time = time(NULL); + localtime_r (&time_time, &tm_time); + + if (strftime(buffer, sizeof(buffer), "=== %F %T %z ===\n", &tm_time) != 0) + { + signal_log (buffer); + } +} + +// FATE 302167, info '(libc) Backtraces' +void +signal_log_backtrace () +{ + static const int N = 100; + void *frames[N]; + size_t size = backtrace (frames, N); + // demangling is not signal safe + signal_log ("Backtrace: (use c++filt to demangle)\n"); + backtrace_symbols_fd (frames, size, signal_log_fd); +} + +void +signal_log_open () +{ + signal_log_fd = -1; + + const char * logfns[] = { + "/var/log/YaST2/signal", + "y2signal.log", + NULL, // sentinel + }; + + for (const char ** logfn_p = &logfns[0]; *logfn_p != NULL; ++logfn_p) + { + signal_log_fd = open (*logfn_p, O_WRONLY | O_CREAT | O_APPEND, 0600); + if (signal_log_fd != -1) + break; + } +} + void signal_handler (int sig) { signal (sig, SIG_IGN); - fprintf (stderr, "YaST got signal %d at YCP file %s:%d\n", - sig, ee.filename ().c_str (), ee.linenumber ()); - y2error ("got signal %d at YCP file %s:%d", - sig, ee.filename ().c_str (), ee.linenumber ()); + + // bnc#493152#c19 only signal-safe functions are allowed + char buffer[200]; + int n = snprintf (buffer, sizeof(buffer), + "YaST got signal %d at YCP file %s:%d\n", + sig, ee.filename ().c_str (), ee.linenumber ()); + if (n >= (int)sizeof(buffer) || n < 0) + strcpy (buffer, "YaST got a signal.\n"); + signal_log_to_fd (STDERR_FILENO, buffer); + + signal_log_open (); + if (signal_log_fd == -1) + { + signal_log_to_fd (STDERR_FILENO, "Could not open log file.\n"); + } + else + { + signal_log_timestamp (); + signal_log (buffer); + signal_log_backtrace (); + + if (close (signal_log_fd) == -1) + perror ("log close"); + } + // bye signal (sig, SIG_DFL); kill ( getpid (), sig); Modified: branches/SuSE-SLE-10-SP4-Branch/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP4-Branch/core/package/yast2-core.changes?rev=65488&r1=65487&r2=65488&view=diff ============================================================================== --- branches/SuSE-SLE-10-SP4-Branch/core/package/yast2-core.changes (original) +++ branches/SuSE-SLE-10-SP4-Branch/core/package/yast2-core.changes Wed Aug 31 19:13:13 2011 @@ -1,4 +1,15 @@ ------------------------------------------------------------------- +Wed Aug 31 19:06:00 CEST 2011 - mvidner@suse.cz + +- Prevent YaST hanging when threads are used (bnc#708367), backport: +- Log the C backtrace when receiving a signal (FATE#302167). +- avoid y2log in both signal handler and forked children (bnc#493152) +- Resurrected logging in the signal handler, into + /var/log/YaST2/signal (or ./y2signal.log) (bnc#493152#c33). +- /var/log/YaST2/signal: do not make it executable +- 2.13.48 + +------------------------------------------------------------------- Wed Aug 31 18:10:21 CEST 2011 - mvidner@suse.cz - Log YCP client arguments only with y2debug, not to reveal AutoYaST -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn2.opensuse.org