[#30872] segv when reentering into Fiber with callcc — sheepman <sheepman@...>

こんばんは、sheepman です。

15 messages 2007/06/01
[#30899] Re: segv when reentering into Fiber with callcc — SASADA Koichi <ko1@...> 2007/06/06

 ささだです。

[#30905] Re: segv when reentering into Fiber with callcc — "Yusuke ENDOH" <mame@...> 2007/06/06

遠藤と申します。

[#30906] Re: segv when reentering into Fiber with callcc — SASADA Koichi <ko1@...> 2007/06/06

 ささだです。

[#30929] secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

51 messages 2007/06/08
[#30930] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <4669066C.2080307@sarion.co.jp>,

[#30934] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

-----BEGIN PGP SIGNED MESSAGE-----

[#30935] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <46694461.4060706@sarion.co.jp>,

[#30936] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

-----BEGIN PGP SIGNED MESSAGE-----

[#30938] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <46697C0B.8060402@sarion.co.jp>,

[#30939] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

-----BEGIN PGP SIGNED MESSAGE-----

[#30940] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <4669DAB0.4050705@sarion.co.jp>,

[#30944] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/09

-----BEGIN PGP SIGNED MESSAGE-----

[#30945] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/09

In article <466AA73C.9030407@sarion.co.jp>,

[#30946] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/09

-----BEGIN PGP SIGNED MESSAGE-----

[#30950] Re: secrand.rb — Nobuyoshi Nakada <nobu@...> 2007/06/11

なかだです。

[#31173] Re: Random — Tanaka Akira <akr@...> 2007/07/10

In article <469253E9.9010203@sarion.co.jp>,

[#31174] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/10

-----BEGIN PGP SIGNED MESSAGE-----

[#31178] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/11

-----BEGIN PGP SIGNED MESSAGE-----

[#31179] Re: Random — Tanaka Akira <akr@...> 2007/07/11

In article <4694338C.7090303@sarion.co.jp>,

[#31183] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/11

-----BEGIN PGP SIGNED MESSAGE-----

[#30971] Linux/ia64で'ucontext_t' undeclared — akira yamada / やまだあきら <akira@...>

最近のRuby 1.9をLinux/ia64上でmakeしようとすると

16 messages 2007/06/13
[#30973] Re: Linux/ia64で'ucontext_t' undeclared — Yukihiro Matsumoto <matz@...> 2007/06/13

まつもと ゆきひろです

[#30974] Re: Linux/ia64で'ucontext_t' undeclared — akira@... 2007/06/13

Yukihiro Matsumoto さんは書きました:

[#30975] Re: Linux/ia64で'ucontext_t' undeclared — Yukihiro Matsumoto <matz@...> 2007/06/13

まつもと ゆきひろです

[ruby-dev:30999] trap(sig, "SYSTEM_DEFAULT")

From: Tanaka Akira <akr@...>
Date: 2007-06-15 10:46:07 UTC
List: ruby-dev #30999
ときおり、デバッグの都合により、SIGSEGV や SIGBUS に対する
signal handler を SIG_DFL にしたいことがあるのですが、Ruby
の trap はそれを許してくれません。

trap で "SIG_DFL" と指定しても、Ruby のデフォルトの、[BUG]
と出てくる signal handler が設定されてしまいます。
そのため、core がまともに作れず、デバッグが厄介な場合があり
ます。

そこで、trap で "SYSTEM_DEFAULT" と指定すると本当に SIG_DFL
になるようにしてみたのですがどうでしょうか。

また、trap の説明に、SIG_DFL で the operating system's
default handler になると書いてあるのは嘘だと思います。

Index: signal.c
===================================================================
--- signal.c	(リビジョン 12550)
+++ signal.c	(作業コピー)
@@ -634,13 +634,62 @@
     VALUE cmd;
 };
 
+static sighandler_t
+default_handler(int sig)
+{
+    sighandler_t func;
+    switch (sig) {
+      case SIGINT:
+#ifdef SIGHUP
+      case SIGHUP:
+#endif
+#ifdef SIGQUIT
+      case SIGQUIT:
+#endif
+#ifdef SIGTERM
+      case SIGTERM:
+#endif
+#ifdef SIGALRM
+      case SIGALRM:
+#endif
+#ifdef SIGUSR1
+      case SIGUSR1:
+#endif
+#ifdef SIGUSR2
+      case SIGUSR2:
+#endif
+        func = sighandler;
+        break;
+#ifdef SIGBUS
+      case SIGBUS:
+        func = sigbus;
+        break;
+#endif
+#ifdef SIGSEGV
+      case SIGSEGV:
+        func = sigsegv;
+        break;
+#endif
+#ifdef SIGPIPE
+      case SIGPIPE:
+        func = sigpipe;
+        break;
+#endif
+      default:
+        func = SIG_DFL;
+        break;
+    }
+
+    return func;
+}
+
 static RETSIGTYPE
 wrong_trap(int sig)
 {
 }
 
 static sighandler_t
-trap_handler(VALUE *cmd)
+trap_handler(VALUE *cmd, int sig)
 {
     sighandler_t func = wrong_trap;
     VALUE command;
@@ -654,22 +703,32 @@
 	    SafeStringValue(command);	/* taint check */
 	    switch (RSTRING_LEN(command)) {
 	      case 0:
-		func = SIG_IGN;
+                goto sig_ign;
 		break;
+              case 14:
+		if (strncmp(RSTRING_PTR(command), "SYSTEM_DEFAULT", 14) == 0) {
+                    func = SIG_DFL;
+                    *cmd = 0;
+		}
+                break;
 	      case 7:
 		if (strncmp(RSTRING_PTR(command), "SIG_IGN", 7) == 0) {
-		    func = SIG_IGN;
+sig_ign:
+                    func = SIG_IGN;
+                    *cmd = 0;
 		}
 		else if (strncmp(RSTRING_PTR(command), "SIG_DFL", 7) == 0) {
-		    func = SIG_DFL;
+sig_dfl:
+                    func = default_handler(sig);
+                    *cmd = 0;
 		}
 		else if (strncmp(RSTRING_PTR(command), "DEFAULT", 7) == 0) {
-		    func = SIG_DFL;
+                    goto sig_dfl;
 		}
 		break;
 	      case 6:
 		if (strncmp(RSTRING_PTR(command), "IGNORE", 6) == 0) {
-		    func = SIG_IGN;
+                    goto sig_ign;
 		}
 		break;
 	      case 4:
@@ -689,9 +748,6 @@
 	    func = sighandler;
 	}
     }
-    if (func == SIG_IGN || func == SIG_DFL) {
-	*cmd = 0;
-    }
 
     return func;
 }
@@ -734,53 +790,6 @@
     return sig;
 }
 
-static sighandler_t
-default_handler(sighandler_t func, int sig)
-{
-    if (func == SIG_DFL) {
-	switch (sig) {
-	  case SIGINT:
-#ifdef SIGHUP
-	  case SIGHUP:
-#endif
-#ifdef SIGQUIT
-	  case SIGQUIT:
-#endif
-#ifdef SIGTERM
-	  case SIGTERM:
-#endif
-#ifdef SIGALRM
-	  case SIGALRM:
-#endif
-#ifdef SIGUSR1
-	  case SIGUSR1:
-#endif
-#ifdef SIGUSR2
-	  case SIGUSR2:
-#endif
-	    func = sighandler;
-	    break;
-#ifdef SIGBUS
-	  case SIGBUS:
-	    func = sigbus;
-	    break;
-#endif
-#ifdef SIGSEGV
-	  case SIGSEGV:
-	    func = sigsegv;
-	    break;
-#endif
-#ifdef SIGPIPE
-	  case SIGPIPE:
-	    func = sigpipe;
-	    break;
-#endif
-	}
-    }
-
-    return func;
-}
-
 static VALUE
 trap(struct trap_arg *arg)
 {
@@ -851,10 +860,12 @@
  * signal name. The command or block specifies code to be run when the
  * signal is raised. If the command is the string ``IGNORE'' or
  * ``SIG_IGN'', the signal will be ignored. If the command is
- * ``DEFAULT'' or ``SIG_DFL'', the operating system's default handler
+ * ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
  * will be invoked. If the command is ``EXIT'', the script will be
  * terminated by the signal. Otherwise, the given command or block
  * will be run.
+ * If the command is ``SYSTEM_DEFAULT'', the operating system's default
+ * handler will be invoked.
  * The special signal name ``EXIT'' or signal number zero will be
  * invoked just prior to program termination.
  * trap returns the previous handler for the given signal.
@@ -885,7 +896,7 @@
     }
     else if (argc == 2) {
 	arg.cmd = argv[1];
-	arg.func = default_handler(trap_handler(&arg.cmd), arg.sig);
+	arg.func = trap_handler(&arg.cmd, arg.sig);
     }
 
     if (OBJ_TAINTED(arg.cmd)) {
-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread

Prev Next