[Rd] Question on parsing R code from C
Simon Urbanek
simon.urbanek at r-project.org
Wed Nov 16 20:59:51 CET 2011
On Nov 16, 2011, at 2:48 PM, KR wrote:
> Simon Urbanek <simon.urbanek <at> r-project.org> writes:
>> Not without seeing the actual code. (And details such as which platform you're
> on).
>> Note that setup_Rmainloop() is the last to set the SETJMP context target so
> you should make sure the stack is
>> still present after it finished (i.e. you can't call it from a sub-function -
> which Rf_initEmbeddedR
>> does) otherwise error without an enclosing context will crash. Or to put it
> other way round, create a
>> context around your parse/eval code (probably the easiest way to do that is to
> use R_ToplevelExec).
>
> I will try to produce the exact code I am using (at the moment it embedded in
> other code you would not be interested in), platforms are Windows XP and
> Windows7-64. Some points:
>
> 1. Actually R_tryEvalSilent (and R_tryEval) calls R_ToplevelExec.
Yes, but that's not where you get the crash.
> Moreover if
> the problem is linked to the SETJMP (which I do not know much about
> unfortunately, my background is C++) it's my understanding that it should
> manifest itself even for other parse and evaluation errors. Instead the problem
> arise if and only if I pass a wrongly escaped string. I.e. rnorm(10a10) does not
> result in a crash.
> Is the R code doing something differently in this specific case?
>
Your crash is in the parsing step, not in the evaluator (if I understand you correctly) and the parsing step is not wrapped in a context - that's my guess based on what you told us.
Cheers,
Simon
> 2. My code is almost exactly the same as:
> http://stackoverflow.com/questions/2463437/r-from-c-simplest-possible-
> helloworld/2464479#2464479
> skipping the EXAMPLE 1 part and passing the capture.output(eval(parse(text="
> <code>"))) string to R_tryEval in EXAMPLE 2.
>
> Cheers,
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
More information about the R-devel
mailing list