Hello R developers, Platform: Windows 2000. Compiler: GNU GCC - 2.95.2 (CRTDLL) I have a C function for evaluating commands using eval(SEXP,SEXP) which is included in a personal make of R.dll. (Similiar to R_Proxy_evaluate() in rproxy_impl.c) Using SETJMP to catch errors works but there is a problem. For example, the following code: if (SETJMP(R_ToplevelContext->cjmpbuf)) // R_ToplevelContext->cjmpbuf R_GlobalContext->cjmpbuf return FALSE; R_CurrentExpr = eval(R_CurrentExpr , rho); will appear to work the first time there is an error, but the second error causes an infinite loop. I have identified the location where the loop occurs. It is in the function jump_to_toplevel() in errors.c inside the for loop: for (c = R_GlobalContext; c; c = c->nextcontext) { ... } I have found a work around for this but is seems cludgy and I don't know the POTENTIAL PROBLEMS that might be introduced. It involves setting up a context and forcing R_GlobalContext's nextcontext to 0, as in the following (by the way, this same approach doesn't work in the example above, which is why I set up a context): begincontext(&thiscontext, 0, CTXT_GENERIC, R_NilValue, R_NilValue, R_NilValue); R_GlobalContext->nextcontext = 0; if (!SETJMP(thiscontext.cjmpbuf)) R_CurrentExpr = eval(R_CurrentExpr , rho); endcontext(&thiscontext); This code solves my problem, however, in certain cases my calling C++ client application cannot catch the error (exception?) that is generated, and my program hard crashes. (A bug in Visual Studio, I think.) For this reason, using SETJMP(R_ToplevelContext->cjmpbuf) as in the first example would probably be preferable in my case because it doesn't generate an exception which must be caught by the C++ client. Note: I am forcing an error to test this by simply calling matrix(x) on a variable x which doesn't exist. I realize that R is meant to run in its own event loop and that this is not a straight-forward problem. However, if anyone able to provide any insight into what might be going or how to handle it on I would be greatful. Thanks, Don Wingate -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._