[R] R unstable and crashes after executing .C

Sole Acha, Xavi x.sole at iconcologia.net
Wed Feb 21 12:08:16 CET 2007

Dear R listers,

I have developed a C function to be executed from R through the ".C" interface. After doing dyn.load, the function executes properly and I get the results. However, after executing my function, R seems to get unstable and crashes (giving a segmentation fault and exiting) whenever I try to do ANYTHING with a relatively large object (creating a new one or even just writing the name of an existing one). 

I use R 2.4.0 under a Linux machine with 1 GB RAM. Below there is an example of execution, so you can get an idea of what is happening:

res <- .C("my_C_function",.....); #The function executes fine and res is ok
dyn.unload("my_C_module.so") #I know this isn't strictly necessary

#Here R is still running, but when I execute:

m <- matrix(0,1000,100); #I try to create a new object and R crashes

*** caught segfault ***
address 0x10, cause 'memory not mapped'

 1: matrix(0, 1000, 100)

Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

Although I tell R to abort and give me the core dump, it doesn't succeed in doing so.

I would be grateful if anyone could tell me what could be the problem with my C function that makes R behave this way?

Thank you very much in advance, and apologies for this long email.

Xavier Solé.

More information about the R-help mailing list