[R] .Call function crashes initializing matrix
wdunlap at tibco.com
Sun Apr 11 02:35:55 CEST 2010
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Erik Wright
> Sent: Saturday, April 10, 2010 3:23 PM
> To: r help
> Subject: [R] .Call function crashes initializing matrix
> I have a C function that I call from R using .Call. I
> recently discovered a bug in my code, and I am not sure if it
> is a problem with what I am doing in C or if it has something
> to do with my use of .Call.
> I have narrowed my problem down to these two C statements:
> int size = 5000;
> double matrix[size][size];
> When I run this in R it crashes, with this message:
> *** caught segfault ***
> address 0xb4141d70, cause 'memory not mapped'
You may be overflowing the stack. Allocate
the space for 'matrix' with the allocation
functions described in section 5.9 of "Writing
R Extensions". They allocate space on the 'heap',
which has much more space than the stack (where
space for 'automatic' variables is allocated).
Typical stack sizes are on the order of few
megabytes and typical heap sizes are in the gigabytes.
Spotfire, TIBCO Software
> It has no problem when size is smaller, like 50. Any idea
> what is going on?
> R version 2.10.1 (2009-12-14)
>  en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> attached base packages:
>  stats graphics grDevices utils datasets methods
>  base
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help