[Rd] mb_m buffer not cleared if parseEval fails

Dirk Eddelbuettel edd at debian.org
Thu Mar 1 17:39:02 CET 2012

Hi Pratibha,

May I suggest to move this over to the rcpp-devel list (where you need to be
subscribed to post)?   I am setting an appropriate Reply-To: now, we should
then also remove the CC for r-devel.

On 1 March 2012 at 11:05, Pratibha Rana wrote:
| Hi,
| I am using RInside for one of the applications that I'm using. The error 
| that occured is as follows.
| When I use  R.parseEval("xyz") if the parse fails then the mb_m is not 
| cleared and hence all subsequent
| calls to R.parseEval fail.
| example:
| when R.parseEval("stringConcatfactoryrandom") is executed the R instance 
| looks like this
|   (gdb) p R
| $7 = (RInside &) @0x7fff13d42d10: {mb_m = {buffer = 
| "stringConcatfactoryrandom"}, global_env = <incomplete type>, verbose_m 
| = false, static instance_ = 0x7fff13d42d10}
| since there's no function called stringConcatfactoryrandom in my R code, 
| the above call fails. The I use the same R instance to call
We could do with a try/catch logic here.  You can either (easiest) wrap your
actual expression in a try() [ or tryCatch() ] and then submit the new
compound expression.

Or we tackle this at the C++ and add a try/catch layer in the member function
RInside::parseEval() --- which never had one as I started with the code from
littler which, being C, never had this type of exception handling.

I do not have to implement this, or try it, but if you get a chance I'd love
to hear how it goes.

| R.parseEval("exists")    and I  get this
| (gdb) p R
| $8 = (RInside &) @0x7fff13d42d10: {mb_m = {buffer = 
| "stringConcatfactoryrandomexists"}, global_env = <incomplete type>, 
| verbose_m = false, static instance_ = 0x7fff13d42d10}
| I think the buffer should be cleared after each call to parseEval

Other approaches may work too. What you suggest would just ignore the error
and carry on.  That may work too, but there is something about this I don't
quite like...

Cheers, Dirk

| Thanks
| Pratibha
| ______________________________________________
| R-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-devel

"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

More information about the R-devel mailing list