[Rcpp-devel] Errors inside RInside

David Ibarra Gómez dibarra at aqualogy.net
Mon Sep 17 13:30:33 CEST 2012


Hi Dirk,

        thank you for the quick answer. Rigth now I'm controlling code to avoid error, anyway I may try something with interective mode (if I fail) and see if it works. Or maybe I'll start using RCpp directly.

Regards



David Ibarra Gomez
Jefe de Proyectos
Dirección de Ingeniería de sistemas
Aqualogy Aqua Ambiente






-----Mensaje original-----
De: Dirk Eddelbuettel [mailto:edd at debian.org]
Enviado el: lunes, 17 de septiembre de 2012 13:19
Para: David Ibarra Gómez
CC: rcpp-devel at lists.r-forge.r-project.org
Asunto: Re: [Rcpp-devel] Errors inside RInside


Hi David,

On 17 September 2012 at 10:20, David Ibarra Gómez wrote:
|                 I am using RInside with MPI. I'm processing several
| time series in parallel (linear regresion and other things). I get an error from R:
|
| "Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
|   contrasts can be applied only to factors with 2 or more levels
| Execution halted"
|
| because of that the execution halts and due to this error the whole
| process halts (is not possible to call MPI_Finalize due to the sudden error):
|
| "---------------------------------------------------------------------
| ----- mpirun has exited due to process rank 0 with PID 2243 on node
| debian exiting without calling "finalize". This may have caused other
| processes in the application to be terminated by signals sent by
| mpirun (as reported here)."
|
| I am wondering if it's possible to get/launch an exception instead of an error.
|
| If I get an exception instead of an error I'll be able to ignore/treat
| the failure for that particular time serie and process the other time series.

There are two things.  First, making RInside more fault-tolerant. Second, MPI.

As for RInside, I actually briefly looked at that the other day as this has been on the list of things to do.  Right now, RInside always sets (in the
RInside::initialize() function)

    Rst.R_Interactive = (Rboolean) FALSE;       // sets interactive() to eval to false

FALSE leads to sudden death after an error. We need to start by setting this to TRUE, but I am unsure what other side effects we get.

Once that it is set to true, then in RInside::parseEval() at

            ans = R_tryEval(VECTOR_ELT(cmdexpr, i), global_env_m, &errorOccurred);
            // NB: we never actually get here if interactice is set to FALSE as it is above
            if (errorOccurred) {
                Rf_error("%s: Error in evaluating R code (%d)\n", programName, status);
                UNPROTECT(2);
                return 1;
            }

we may have a chance to do something more than the Rf_error() and maybe do something other than return. I'm not sure what yet --- but maybe you want to take a stab and experiment?

If and when R terminates more gracefully, MPI will probably be happier too. It does need its finalize() call at the end...

So to sum up: right now, in non-interactice mode, the error will leads to abrupt end of RInside.  We should probably start by trying something in interactive mode.

Dirk

--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

Disclaimer: http://disclaimer.aqualogy.net/


More information about the Rcpp-devel mailing list