On May 19, 2009, at 4:30 AM, goon83 wrote:
Hi everyone!
I meet one problem when embedding R in C code, when I run the the
R code in one child thread ,
it always print error info:
Error: C stack usage is too close to the limit
I also try to set R_CStackLimit = (uintptr_t)-1 to disable the C
stack check as the R-exts doc say,
but it still does not work, the error info still exist.
That is the way to do it (and other project use it successfully) - the
fact that it doesn't work means that you probably do it at the wrong
place (you must set it *after* Rf_initialize_R).
Cheers,
Simon
Besides it is interesting that if i put the R code in the main
thread(don't create any thread), it work, and the E-exts doc say
that "Embedded R is designed to be run in the main thread, and all
the testing is done in that context." so i wonder is it that
Embedded R can not run in the child thread ?
so, can anybody give some help or suggestion about this problem,
any response will be appreciated, tks in advance.
***********************
Bin Dong
BUAA, Beijing PR China
goo...@126.com
***********************
ps: my code, system info and error information list behand
-----------------------------
1, my example code lists here:
-----------------------------
#include ....
void *ts_thread(){
SEXP e, tmp;
int hadError;
int argc = 0;
char *argv[1];
ParseStatus status;
init_R(argc, argv);
PROTECT(tmp = mkString("{print(lh)}"));
PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue));
PrintValue(e);
R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError);
UNPROTECT(2);
end_R();
}
int main(int argc, char *argv[]){
pthread_t th1;
int iret1;
iret1 = pthread_create(&th1, NULL, ts_thread,NULL);
pthread_join(th1, NULL);
printf("Thread 1 return:%d\n", iret1);
return 0;
}
-----------------------------------
2, My os and compiler is:
-----------------------------------
Linux debian 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686
GNU/Linux
gcc version 4.3.2 (Debian 4.3.2-1.1)
-----------------------------------
3, the error info:
------------------------------------
g...@debian:~/library/R-source/R-2.9.0/tests/Embedding$ ./Rar
Error: C stack usage is too close to the limit
Error: C stack usage is too close to the limit
R version 2.7.1 (2008-06-23)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
expression({
print(lh)
})
Error: C stack usage is too close to the limit
Thread 1 return:0
------------------------------------------
[[alternative HTML version deleted]]
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel