Skip to content

segfault in embedded r after call to repldlldo1

2 messages · Carl Martin Grewe, Simon Urbanek

#
Dear R developers,

i've got a question concerning an embedded R instance. I called the 
initialization routines as seen in the "writing extensions" guide 
(Rf_initialize, setup_Rmainloop and R_ReplDLLinit). I also changed the 
function callback pointer of readconsole and writeconsoleex to my local 
functions.

when i call mainloop there is no problem and the commands are evaluated 
as expected. because i don't want R to run in an own thread and my app 
should keep the control i want to use repldlldo1. within the readconsole 
as long as i copy commandlines containing valid R commands function to 
R's buffer all things are fine. but when i copy a non valid command, R 
singals segfault after passing the error message, that the given object 
is not valid. this happens in call to eval(R_CurrentExpr, rho) in 
repldlldo1. i tried to comapare both ways (mainloop vs. 
repldlldo+repldllinit) but actually cannot find a significant difference.

can anyone please help me with this problem, i'm stucked with this 
because i don't know the inside of R and the datastructures.


some additional information:
c++, runtime loaded libR, 64-bit linux, 2.11.1 release (but also happens 
with 2.10.1)

look farward to hearing from you.

thanks,
martin
#
On Aug 20, 2010, at 12:14 PM, Carl Martin Grewe wrote:

            
I fear we can't help you without a reproducible example. One thing to keep in mind is that R_ReplDLLinit uses setjmp to setup the top-level context so you have to make sure you're not using any local variables that could be on the stack from R_ReplDLLdo1 as it will get lost (and function calls of course).

Cheers,
Simon