Mailinglist Archive: yast-commit (396 mails)

< Previous Next >
[yast-commit] r65234 - in /branches/SuSE-SLE-10-SP3-Branch/core: VERSION agent-system/src/ShellCommand.cc liby2/src/Y2ProgramComponent.cc liby2/src/genericfrontend.cc package/yast2-core.changes
Author: mvidner
Date: Fri Aug 5 10:55:11 2011
New Revision: 65234

URL: http://svn.opensuse.org/viewcvs/yast?rev=65234&view=rev
Log:
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

Modified:
branches/SuSE-SLE-10-SP3-Branch/core/VERSION
branches/SuSE-SLE-10-SP3-Branch/core/agent-system/src/ShellCommand.cc
branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/Y2ProgramComponent.cc
branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/genericfrontend.cc
branches/SuSE-SLE-10-SP3-Branch/core/package/yast2-core.changes

Modified: branches/SuSE-SLE-10-SP3-Branch/core/VERSION
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/core/VERSION?rev=65234&r1=65233&r2=65234&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/core/VERSION (original)
+++ branches/SuSE-SLE-10-SP3-Branch/core/VERSION Fri Aug 5 10:55:11 2011
@@ -1 +1 @@
-2.13.45
+2.13.45.1

Modified: branches/SuSE-SLE-10-SP3-Branch/core/agent-system/src/ShellCommand.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/core/agent-system/src/ShellCommand.cc?rev=65234&r1=65233&r2=65234&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/core/agent-system/src/ShellCommand.cc
(original)
+++ branches/SuSE-SLE-10-SP3-Branch/core/agent-system/src/ShellCommand.cc Fri
Aug 5 10:55:11 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-SP3-Branch/core/liby2/src/Y2ProgramComponent.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/Y2ProgramComponent.cc?rev=65234&r1=65233&r2=65234&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/Y2ProgramComponent.cc
(original)
+++ branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/Y2ProgramComponent.cc Fri
Aug 5 10:55:11 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-SP3-Branch/core/liby2/src/genericfrontend.cc
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/genericfrontend.cc?rev=65234&r1=65233&r2=65234&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/genericfrontend.cc (original)
+++ branches/SuSE-SLE-10-SP3-Branch/core/liby2/src/genericfrontend.cc Fri Aug
5 10:55:11 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-SP3-Branch/core/package/yast2-core.changes
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-SLE-10-SP3-Branch/core/package/yast2-core.changes?rev=65234&r1=65233&r2=65234&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP3-Branch/core/package/yast2-core.changes (original)
+++ branches/SuSE-SLE-10-SP3-Branch/core/package/yast2-core.changes Fri Aug 5
10:55:11 2011
@@ -1,4 +1,15 @@
-------------------------------------------------------------------
+Fri Aug 5 08:54:30 CEST 2011 - mvidner@xxxxxxx
+
+- 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.45.1
+
+-------------------------------------------------------------------
Thu Nov 5 15:11:47 CET 2009 - jsrain@xxxxxxx

- close unneeded file descriptors before execing another

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages