[mercury-users] Mercury runtime problem on Windows

Michael Day mikeday at yeslogic.com
Thu Aug 13 22:28:42 AEST 2009


Hi Paul,

> AIUI this is for the detection and slightly-more-graceful handling of memory
> access errors.  In some places in the runtime we use mprotect() to ensure that
> reads or writes to that memory are caught as errors, I forget exactly what this
> is for but perhaps to catch stack overruns, this may be related to our SIGSERV
> handler.

In this case it seems that the signal handler is only necessary to give 
a suitable error message for runtime or program errors. Since in this 
case it is actually causing a serious error, and is not required for 
correct program operation, it would be nice if it were optional.

Can this be done? It seems to be simply a matter of ignoring the return 
value, or perhaps printing a message or aborting only in debug grades?

> That's a good point.  I'd recommend writing a C program that trys to install
> signal handlers and spawning multiple copies of that program to see if this
> problem occurs is independently of Mercury.

I've tried this:

#include <stdlib.h>
#include <stdio.h>
#include <signal.h>

void handler(int x)
{
}

int main()
{
     if (signal(SIGSEGV, handler) == SIG_ERR)
     {
         printf("error\n");
     }

     return 0;
}

Unfortunately I haven't been able to reproduce the problem yet.

We have also experienced this issue on Windows 2000 when running 
binaries linked with OpenSSL. The problem goes away when the binary is 
not linked with OpenSSL. I have no idea why this is, unless the OpenSSL 
library is doing something very tricky during initialisation. Since it 
is a static library, not a DLL, I'm not sure if that's even possible.

Either way, the dependence on installing this signal handler is a real 
drag that is impossible for us to work around, as it takes place before 
main/2 is even called.

Best regards,

Michael

-- 
Print XML with Prince!
http://www.princexml.com
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list