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-ext doc say,
   but it still does not work. 

   it is interesting that if i put the R code in the main thread(don't create any thread), it work.

   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
goon83@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:
------------------------------------
goon@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]]


