[m-dev.] Re: Linux stack overflow problem

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


On 07-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On hg (Linux 2.2.13), the following program
> 
> 	:- module hello.
> 	:- interface.
> 	:- import_module io.
> 
> 	:- pred main(io__state::di, io__state::uo) is det.
> 
> 	:- implementation.
> 
> 	main --> main, main.
> 
> results in a non-informative "segmentation fault" message rather than
> a "stack overflow" message.
> 
> There seem to be several bugs involved:
> 
> 	- The autoconf test for sigcontext_struct uses signal() rather
> 	  than sigaction(), but the Mercury runtime code which actually
> 	  installs the signal handler uses sigaction() if the system has it.

I've been thinking about this one.  We have tested whether we have
sigaction in the configuration script.  It should be OK to use sigaction
in the runtime.

The code in configure.in is more conservative than it could be -- it
could force the tests a little harder by using sigaction() if defined,
and signal() otherwise.  But this is just going to make the tests more
complicated than they already are, and I guess you have to worry about
what to do if it fails (fallback on signal()?  but signal() is
untested!).

So this code is not wrong, it's just not testing all the known features
at one time. 

> 
> 	- The handler passed to sigaction() is a handler that expects
> 	  a sigcontext struct, rather than one which expects a siginfo,
> 	  but we pass the SA_SIGINFO flag to sigaction, which means that
> 	  the signal will be called with a siginfo rather than a sigcontext.

Yep, this is a problem.

I think the reason why it stopped working is that Linux started to
implment siginfo.  Unfortunately the implementation on our machines
seems to be incomplete -- siginfo has the signal number, but the si_code
and si_addr fields are wrong.

-- 
       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