Linux NILFS development
 help / color / mirror / Atom feed
From: Ryusuke Konishi <ryusuke-sG5X7nlA6pw@public.gmane.org>
To: users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org,
	admin-/LHdS3kC8BfYtjvyW6yDsg@public.gmane.org
Subject: Re: cleanerd segfault
Date: Thu, 05 Feb 2009 18:19:04 +0900 (JST)	[thread overview]
Message-ID: <20090205.181904.55833415.ryusuke@osrg.net> (raw)
In-Reply-To: <lB4DD31fNVpx.grrKfnNr-GG6YVgmNXeLOQU1ULcgDhA@public.gmane.org>

On Thu,  5 Feb 2009 08:52:32 +0100, admin-/LHdS3kC8BfYtjvyW6yDsg@public.gmane.org wrote:
> I can confirm that it is also reproducable on a newly created nilfs2
> populated with some files.

All right.
Could you try the following patch against nilfs2-utils ?

This makes cleanerd which can dump backtrace to /var/log/segv_xxx.

To enable the feature, you need gdb and a 'backtrace' script
available on http://samba.org/ftp/unpacked/junkcode/segv_handler/


Regards,
Ryusuke

--
diff --git a/sbin/cleanerd/Makefile.am b/sbin/cleanerd/Makefile.am
index e6b2553..488518e 100644
--- a/sbin/cleanerd/Makefile.am
+++ b/sbin/cleanerd/Makefile.am
@@ -8,7 +8,7 @@ sbin_PROGRAMS = nilfs_cleanerd
 
 nilfs_cleanerd_SOURCES = cleanerd.c cldconfig.c vector.c \
 	cleanerd.h cldconfig.h vector.h
-nilfs_cleanerd_CFLAGS = -Wall
+nilfs_cleanerd_CFLAGS = -Wall -g
 nilfs_cleanerd_CPPFLAGS = -I$(top_srcdir)/include \
 	-DSYSCONFDIR=\"$(sysconfdir)\" -D_GNU_SOURCE
 nilfs_cleanerd_LDADD = $(top_builddir)/lib/libnilfs.la
diff --git a/sbin/cleanerd/cleanerd.c b/sbin/cleanerd/cleanerd.c
index cae22be..5f67e51 100644
--- a/sbin/cleanerd/cleanerd.c
+++ b/sbin/cleanerd/cleanerd.c
@@ -829,6 +829,46 @@ static int set_sighup_handler(void)
 	return sigaction(SIGHUP, &act, NULL);
 }
 
+/*
+ * The following part is based on segv_handler by Andrew Tridgell
+ * found at http://samba.org/ftp/unpacked/junkcode/segv_handler/
+ *
+ * To enable this feature, install gdb and 'backtrace' script available
+ * on the above site.
+ */
+static RETSIGTYPE handle_segv(int signum)
+{
+	char cmd[100];
+	char progname[100];
+	char *p;
+	int n;
+
+	n = readlink("/proc/self/exe",progname,sizeof(progname));
+	progname[n] = 0;
+
+	p = strrchr(progname, '/');
+	*p = 0;
+	
+	snprintf(cmd, sizeof(cmd),
+		 "backtrace %d > /var/log/segv_%s.%d.out 2>&1", 
+		 (int)getpid(), p+1, (int)getpid());
+	system(cmd);
+	signal(signum, SIG_DFL);
+}
+
+static int set_segv_handler(void)
+{
+	struct sigaction act;
+
+	act.sa_handler = handle_segv;
+	sigfillset(&act.sa_mask);
+	act.sa_flags = 0;
+	return sigaction(SIGSEGV, &act, NULL) || sigaction(SIGBUS, &act, NULL);
+}
+/*
+ * End of segv_handler
+ */
+
 #define timeval_to_timespec(tv, ts)		\
 do {						\
 	(ts)->tv_sec = (tv)->tv_sec;		\
@@ -859,6 +899,10 @@ static int nilfs_cleanerd_clean_loop(struct nilfs_cleanerd *cleanerd)
 		syslog(LOG_ERR, "cannot set SIGHUP signal handler: %m");
 		return -1;
 	}
+	if (set_segv_handler() < 0) {
+		syslog(LOG_ERR, "cannot set SIGSEGV signal handler: %m");
+		return -1;
+	}
 
 	nilfs_cleanerd_reload_config = 0;
 
-- 
1.5.6.5

  parent reply	other threads:[~2009-02-05  9:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-05  7:52 cleanerd segfault admin-/LHdS3kC8BfYtjvyW6yDsg
     [not found] ` <lB4DD31fNVpx.grrKfnNr-GG6YVgmNXeLOQU1ULcgDhA@public.gmane.org>
2009-02-05  9:19   ` Ryusuke Konishi [this message]
     [not found]     ` <20090205.181904.55833415.ryusuke-sG5X7nlA6pw@public.gmane.org>
2009-02-07 11:38       ` Ryusuke Konishi
     [not found]         ` <20090207.203808.94866640.ryusuke-sG5X7nlA6pw@public.gmane.org>
2009-02-08 18:09           ` Ryusuke Konishi
  -- strict thread matches above, loose matches on Subject: below --
2009-02-05  7:17 admin-/LHdS3kC8BfYtjvyW6yDsg
2009-02-05  6:01 David Arendt
     [not found] ` <498A80B5.9080007-/LHdS3kC8BfYtjvyW6yDsg@public.gmane.org>
2009-02-05  6:54   ` Ryusuke Konishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090205.181904.55833415.ryusuke@osrg.net \
    --to=ryusuke-sg5x7nla6pw@public.gmane.org \
    --cc=admin-/LHdS3kC8BfYtjvyW6yDsg@public.gmane.org \
    --cc=users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox