-------- Original Message -------- Subject: Re: [Rd] segfault in embedded r after call to repldlldo1 Date: Mon, 23 Aug 2010 12:46:07 +0200 From: Carl Martin Grewe To: Simon Urbanek On 08/20/2010 06:48 PM, Simon Urbanek wrote: > On Aug 20, 2010, at 12:14 PM, Carl Martin Grewe wrote: > > >> 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. >> >> > 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 > > Hi Simon, thank you very much. after some problems with your answer first (not very familiar with longjumps) and the assumption R would just return from R_ReplDLLdo1 after the errormessage i finally found the solution. calling R_ReplDLLinit right before R_ReplDLLdo1did the trick for me. think it's because R_ReplDLLinit just saves the callers context, like you said, and comming back to this point after an errormessage. am i right? cheers, martin >> 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 >> >> ______________________________________________ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> > -- Carl Martin Grewe Email : grewe@zib.de Internet : http://www.zib.de Tel : +49 30 841 85 352 Fax : +49 30 841 85 107 Konrad Zuse-Zentrum fuer Informationstechnik Berlin (ZIB) Takustr. 7 D-14195 Berlin-Dahlem Germany [[alternative HTML version deleted]]