[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] Re: trapping segfaults on mac os x
From: |
Camm Maguire |
Subject: |
Re: [Gcl-devel] Re: trapping segfaults on mac os x |
Date: |
Wed, 21 Jul 2010 14:57:03 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Greetings, and thank you again so much! Am checking it out now. It
looks like it might work on mingw too.
Take care,
Bruno Haible <address@hidden> writes:
> Hi Camm,
>
>> The mac does not
>> appear to be trapping SIGSEGV via sigaction in the standard way (for
>> SGC garbage collection). Under gdb, the process appears to receive
>> something straight from the kernel, EXC_BAD_ACCESS, and does not
>> trigger or enter the handler at all. Do you have any suggestion here?
>
> Use GNU libsigsegv <http://www.gnu.org/software/libsigsegv/>. It's made
> for this purpose.
>
>> Do you know why the following simple program does not call
>> the handler on macosx?
>>
>> =============================================================================
>> f.c
>> =============================================================================
>> #include <sys/mman.h>
>> #include <stdio.h>
>> #include <signal.h>
>>
>> void
>> h(int s,long c,void *scp,char *a) {
>>
>> printf("foo\n");
>>
>> }
>>
>> int
>> main(int argc,char * argv[]) {
>>
>> char b1[4096*2],*b=b1;
>> struct sigaction siga;
>>
>> b=(char *)(((unsigned long)b+4095) & ~4095);
>> siga.sa_handler=(void *)h;
>> siga.sa_flags=SA_RESTART|SA_SIGINFO|SA_RESETHAND;
>> sigemptyset(&siga.sa_mask);
>> sigaction(SIGSEGV,&siga,0);
>> mprotect(b,sizeof(b),PROT_READ);
>> b[0]=1;
>> return 0;
>> }
>> =============================================================================
>
> Short explanation: Things just don't work this way on MacOS X.
>
> Long explanation: When a fault occurs in MacOS X, the OS (Mach) first sends a
> message to the exception port of the current thread, then a message to the
> exception port of the process, and that's it. You need to catch these message.
> libsigsegv does that. gdb does that as well.
>
> Bruno
>
>
>
>
--
Camm Maguire address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah