Skip to content

Embedded R, last errormessage, and stack smashing

4 messages · Simon Urbanek, Jeffrey Horner, Laurent Gautier

#
The only way to overcome the problem I can find is to tweak the
R_CStackLimit with:

R_CStackLimit = (uintptr_t) -1;

The question I am having now is: what are the implications of doing
so, that is what are the potential problems ?

The R-extensions manual says:
" Stack-checking can be disabled by seting R_CStackLimit =
(uintptr_t)-1, but it is better to
if possible set appropriate values. (What these are and how to
determine them are OS-specific,
and the stack size limit may differ for secondary threads. If you have
a choice of stack size, at
least 8Mb is recommended.)"
I am not very sure of how an appropriate value can be determined.

I looked around, and the JRI (Java/R Interface) is just disabling
stack checking for example.


Thanks,


Laurent


2008/6/30 Laurent Gautier <lgautier at gmail.com>:
#
Laurent,
On Jul 16, 2008, at 9:02 AM, Laurent Gautier wrote:

            
The implications are that you are disabling stack checks, i.e. R won't  
be able to detect stack overflows.
You can have a look at R sources which do this - the basic idea (if no  
OS-specific method exists) is to fetch an address of a local variable  
which will be on the stack and then add as much space as the size of  
the stack is. On some systems there is an API to find the stack of the  
current thread. However, this works only if you guarantee that you'll  
be calling R from a specific thread (which is generally a good idea,  
though).
JRI is quite general and supports different use models - one allows R  
to be called from different threads (with appropriate care and  
synchronization), so it has no choice but to disable the check because  
the stack will change across threads.

Cheers,
Simon
#
Laurent Gautier wrote on 07/16/2008 08:02 AM:
The problem is a program crash without saving data. Stack overflow is 
usually caused by either infinite recursion or very large stack (i.e. 
local) variables.

I've always disabled stack checking in rapache, and I never knew why the 
checking was added to R, but again wikipedia has merit:

http://en.wikipedia.org/wiki/Stack_overflow

Jeff

  
    
  
#
2008/7/16 Jeffrey Horner <jeff.horner at vanderbilt.edu>:
I think that R limits the number of recursions by checking how nested
an evaluation is.