Skip to content

Instantly share code, notes, and snippets.

@mlt
Last active November 30, 2018 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlt/d8ee0be6186f9847d41bf88888e75713 to your computer and use it in GitHub Desktop.
Save mlt/d8ee0be6186f9847d41bf88888e75713 to your computer and use it in GitHub Desktop.
R_ParseVector won't report an error to embedder. Modified example from tests/Embedding/
mlt@ubuntu-vm:~/r-base-3.4.4/tests/Embedding$ R_HOME=/usr/lib/R ./RParseEval --slave || echo $?
Error: bad value
Fatal error: unable to initialize the JIT
2
#include "embeddedRCall.h"
#include <R_ext/Parse.h>
int
main(int argc, char *argv[])
{
SEXP e, tmp;
int hadError;
ParseStatus status;
init_R(argc, argv);
PROTECT(tmp = mkString("{deadbeef<-function(,bad){};plot(1:10, pch=\"+\"); print(1:10)}"));
PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue));
if (status != PARSE_OK)
{
printf("R_suicide is called instead of me because it longjmp into terminated setuploop with messed up doneit\n");
printf("We need a wrapper for embedded R around R_ParseVector that would SETJMP(R_Toplevel.cjmpbuf) first.\n");
}
PrintValue(e);
R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError);
UNPROTECT(2);
end_R();
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment