From therneau at mayo.edu  Tue Mar 27 15:22:38 2012
From: therneau at mayo.edu (Terry Therneau)
Date: Tue, 27 Mar 2012 08:22:38 -0500
Subject: [Rd] PROTECT help
In-Reply-To: <4F7179A3.9060608@kent.ac.uk>
References: <4F7179A3.9060608@kent.ac.uk>
Message-ID: <4F71BF1E.7050600@mayo.edu>

I received the following note this AM.  The problem is, I'm not quite 
sure how to fix it.
Can one use PROTECT(coxlist(eval(PROTECT.... , do I create an 
intermediate variable, or otherwise?

I'm willing to update the code if someone will give me a pointer to the 
right documentation.  This particular chunk was written when there was a 
lot of change going on in the callback mechanism and so there might be a 
safer and/or simpler and/or more standard aproach by now. The routine in 
question has to do with penalized Cox models, the C code needs to get 
the value of the penalty and the penalty is an arbitrary S expression 
passed down from top level.

Terry T

----------------------------

In survival_2.36-12 (and earlier), in the function cox_callback() at
cox_Rcallback.c:40:

     PROTECT(coxlist=eval(lang2(fexpr,data),rho));

the return value of the call to lang2() is vulnerable if allocations
within eval() give rise to garbage collection.

(Discovered during CXXR development.)

Andrew



[Rd] PROTECT help
Terry Therneau