Re: [Rd] PROTECT help

From: Terry Therneau <therneau_at_mayo.edu>
Date: Tue, 27 Mar 2012 09:05:04 -0500

Brian & Duncan:

   Thanks. This was exactly what I needed to know.

Terry

On 03/27/2012 08:41 AM, Prof Brian Ripley wrote:
> On 27/03/2012 14:22, Terry Therneau wrote:
>> 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?
>
> You can, but I find it easiest to follow if you create an intermediate
> variable. Look for example at unique.c:
>
> SEXP call, r;
> PROTECT(call = lang2(install("as.character"), s));
> PROTECT(r = eval(call, env));
> UNPROTECT(2);
> return r;
>
>
>
>>
>> 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
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 27 Mar 2012 - 14:07:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 27 Mar 2012 - 15:10:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive