Re: Bus error

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches,gmane.comp.gnu.m4.bugs
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[dropping bug-gnulib, adding m4-patches]

According to Bruno Haible on 12/6/2008 8:45 AM:
> Eric Blake wrote:
>> maybe swapping the order will help, where I install the
>> SIGBUS handler first, and then c_stack_action can optionally install an
>> alternate handler on platforms where it is needed for stack overflow?
> 
> Yes, I was going to propose this too.

I'm installing this on the stackovf branch (which I still need to merge
into both branch-1.6 and master).  I'm also debating whether to release m4
1.4.13 (it depends on how long it takes me to get m4 1.6 in nice shape);
but if I do end up releasing 1.4.13, this patch is on the list for
inclusion on branch-1.4.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkk6vSkACgkQ84KuGfSFAYBDcgCeOXmBpVawBbrW71yG1xTUrSAd
TTEAoM7ReoUIjGejRZBqMuuPWN8yNhar
=ATor
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch386 (text/plain, 2.5 KB)
From f66f95f60436fe3c8e805268338fbfb1087a385d Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Sat, 6 Dec 2008 10:53:22 -0700
Subject: [PATCH] Don't override signal handlers installed by c-stack.

* src/m4.c (main): Reorder installation of signal handlers, so we
don't trash a SIGBUS handler installed by c-stack.  Also provide a
SIGSEGV fallback, for platforms where c-stack combined with
libsigsegv uses something lower level than SIGSEGV.

Signed-off-by: Eric Blake <[email protected]>
---
 ChangeLog |    8 ++++++++
 src/m4.c  |   10 +++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f13b710..0dab381 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2008-12-06  Eric Blake  <[email protected]>
 
+	Don't override signal handlers installed by c-stack.
+	* src/m4.c (main): Reorder installation of signal handlers, so we
+	don't trash a SIGBUS handler installed by c-stack.  Also provide a
+	SIGSEGV fallback, for platforms where c-stack combined with
+	libsigsegv uses something lower level than SIGSEGV.
+
+2008-12-06  Eric Blake  <[email protected]>
+
 	Upgrade to FDL 1.3, keep COPYING in repository.
 	* Makefile.am (MAINTAINERCLEANFILES): Don't remove COPYING.
 	* .cvsignore: Don't ignore it.
diff --git a/src/m4.c b/src/m4.c
index a24f82d..6031797 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -466,9 +466,10 @@ main (int argc, char *const *argv, char *const *envp)
 
   /* Stack overflow and program error handling.  Ignore failure to
      install a handler, since this is merely for improved output on
-     crash, and we should never crash ;).  */
-  if (c_stack_action (fault_handler) == 0)
-    nesting_limit = 0;
+     crash, and we should never crash ;).  We install SIGBUS and
+     SIGSEGV handlers prior to using the c-stack module; depending on
+     the platform, c-stack will then override none, SIGSEGV, or both
+     handlers.  */
   program_error_message
     = xasprintf (_("internal error detected; please report this bug to <%s>"),
                  PACKAGE_BUGREPORT);
@@ -483,10 +484,13 @@ main (int argc, char *const *argv, char *const *envp)
      to default signal behavior.  */
   act.sa_flags = SA_NODEFER | SA_RESETHAND;
   act.sa_handler = fault_handler;
+  sigaction (SIGSEGV, &act, NULL);
   sigaction (SIGABRT, &act, NULL);
   sigaction (SIGILL, &act, NULL);
   sigaction (SIGFPE, &act, NULL);
   sigaction (SIGBUS, &act, NULL);
+  if (c_stack_action (fault_handler) == 0)
+    nesting_limit = 0;
 
 #ifdef DEBUG_STKOVF
   /* Make it easier to test our fault handlers.  Exporting M4_CRASH=0
-- 
1.6.0.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.