[m-dev.] for review: Linux stack overflow fix.

Tyson Dowd trd at cs.mu.OZ.AU
Mon Sep 11 10:09:16 AEDT 2000


Here's a diff to fix the Linux stack overflow problems.

===================================================================


Estimated hours taken: 2

runtime/mercury_signal.c:
	Don't set SA_SIGINFO if we expect a struct sigcontext to be
	passed to us.
	Fix some incorrect comments in #defines.

runtime/mercury_memory_handlers.c:
	Change the stack dump message, since I am tired of people
	telling me that they recompiled with --low-level-debug and
	didn't get a stack dump.


Index: runtime/mercury_memory_handlers.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_handlers.c,v
retrieving revision 1.14
diff -u -r1.14 mercury_memory_handlers.c
--- runtime/mercury_memory_handlers.c	2000/08/03 06:18:49	1.14
+++ runtime/mercury_memory_handlers.c	2000/09/10 22:24:05
@@ -946,7 +946,7 @@
 #ifndef	MR_LOWLEVEL_DEBUG
 
 	const char *msg =
-		"You can get a stack dump by using `--low-level-debug'\n";
+		"You can get a stack dump by recompiling in a debugging grade.\n";
 	write(STDERR, msg, strlen(msg));
 
 #else /* MR_LOWLEVEL_DEBUG */
Index: runtime/mercury_signal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_signal.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_signal.c
--- runtime/mercury_signal.c	2000/08/03 06:18:53	1.7
+++ runtime/mercury_signal.c	2000/09/10 21:52:02
@@ -91,7 +91,18 @@
 	struct sigaction	act;
 
 	if (need_info) {
+	/*
+	** If we are using sigcontext struct, it means the configuration
+	** tests for SIGINFO have failed in some way (an
+	** incomplete implementation of siginfo perhaps), and so when we
+	** request signals, we should not ask for SA_SIGINFO, since our
+	** handler will not be of this type.
+	*/
+#if	defined(HAVE_SIGCONTEXT_STRUCT)
+		act.sa_flags = SA_RESTART;
+#else	/* not HAVE_SIGCONTEXT_STRUCT */
 		act.sa_flags = SA_SIGINFO | SA_RESTART;
+#endif
 	} else {
 		act.sa_flags = SA_RESTART;
 	}
@@ -107,12 +118,12 @@
 		exit(1);
 	}
 
-#else /* not HAVE_SIGINFO_T */
+#else /* not HAVE_SIGACTION */
 
 	if (signal(sig, handler) == SIG_ERR) {
 		perror(error_message);
 		exit(1);
 	}
-#endif /* not HAVE_SIGINFO_T */
+#endif /* not HAVE_SIGACTION */
 }
 


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list