Skip to content
Prev 29418 / 63424 Next

Embedded R, last errormessage, and stack smashing

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