#8371: ghci byte compiler + FFI crashes when used with embedded R-------------------------------+----------------------------------
Reporter: dsamperi | Owner:Resolution: | Keywords:
Type: bug | Status: new
Priority: normal | Milestone:
Component: GHCi | Version: 7.6.3
Operating System: Linux | Architecture: x86_64 (amd64)-------------------------------+----------------------------------
Type of failure: GHCi crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
Comment (by rwbarton):
I can reproduce this without ghci, by putting a forkIO around the body of
main (and adding a threadDelay in the main thread).
It seems to just be an interaction between R's method for determining the
base address of the stack and the way pthread allocates stacks for new
threads. Try this C example program `pt.c`.
{{{
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
int Rf_initEmbeddedR(int argc, char **argv);
void *foo(void *blah)
{
char *args[] = {"pt", "--gui=none", "--silent", "--vanilla"};
int r;
setenv("R_HOME", "/usr/lib/R", 1);
r = Rf_initEmbeddedR(sizeof(args)/sizeof(args[0]), args);
printf("r = %d\n", r);
}
int main(void)
{
pthread_t tid;
pthread_create(&tid, NULL, foo, NULL);
while (1)
sleep(1);
return 0;
}
}}}
{{{
rwbarton@adjunction:/tmp$ gcc -o pt pt.c -lpthread -lR
rwbarton@adjunction:/tmp$ ./pt
Error: C stack usage is too close to the limitr = 1
Error: C stack usage is too close to the limit
}}}
It would probably be best to just disable R's stack limit checks, if
possible.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8371#comment:6>