[racket] FFI crashing Racket
It appears, from some quick googling, that createIndex enables
multithreading in clang, which might explain this, depending on the
threading libraries used.
Sam
On Oct 19, 2014 9:24 AM, "Matthew Flatt" <mflatt at cs.utah.edu> wrote:
> It appears that calling clang_createIndex() sets the handler for
> SIGSEGV, which interferes with Racket's own SIGSEGV handler to
> implement the GC's write barrier.
>
> The program below illustrates. It sets the handler before and after a
> call to clang_createIndex() and shows that the handler has been changed
> after the call. If you comment out the clang_createIndex() call, then
> the handler is unchanged.
>
> I have no idea why clang_createIndex() would set the SIGSEGV handler or
> whether that can be disabled.
>
> ----------------------------------------
>
> #include <stdio.h>
> #include <string.h>
> #include <signal.h>
> #include <sys/types.h>
> #include <unistd.h>
>
> typedef void *CXIndex;
> extern CXIndex clang_createIndex(int, int);
>
> void fault_handler()
> {
> printf("fault\n");
> }
>
> void check()
> {
> struct sigaction act, oact;
> memset(&act, 0, sizeof(act));
> act.sa_sigaction = fault_handler;
> sigemptyset(&act.sa_mask);
> sigaction(SIGSEGV, &act, &oact);
>
> printf("%p %d\n", oact.sa_sigaction, oact.sa_sigaction == fault_handler);
> }
>
> int main() {
> void *dl;
>
> check();
>
> clang_createIndex(0, 0);
>
> check();
>
> return 0;
> }
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141019/884cdb50/attachment.html>