I think you're right, and I think I've found the offending code 
(https://github.com/patperry/r-utf8/blob/master/src/as_utf8.c#L111):

     if (!raw || ce == CE_BYTES || ce == CE_NATIVE) {
         if (!duped) {
             PROTECT(ans = duplicate(ans)); nprot++;
             duped = 1;
         }
         SET_STRING_ELT(ans, i,
                        mkCharLenCE((const char *)str,
                                    size, CE_UTF8));
     }

UNPROTECT(1); nprot--;

Thanks for the suggestion.


Patrick

> Joshua Ulrich <mailto:josh.m.ulr...@gmail.com>
> November 21, 2017 at 7:13 AM
> On Mon, Nov 20, 2017 at 8:34 PM, Patrick Perry<ppe...@stern.nyu.edu>  wrote:
>> One of my packages has what I believe to be spurious rchk warnings:
>>
>> From
>> https://raw.githubusercontent.com/kalibera/cran-checks/master/rchk/results/utf8.out
>>
>> Package utf8 version 1.1.0
>> Package built using 73757/R 3.5.0; x86_64-pc-linux-gnu; 2017-11-20 22:02:23
>> UTC; unix
>> Checked with rchk version 63f79d910f5835174fcaa5a0a7d2409348f7d2ac
>> More information at
>> https://github.com/kalibera/cran-checks/blob/master/rchk/PROTECT.md
>>
>> Function rutf8_as_utf8
>>    [UP] unprotected variable ans while calling allocating function
>> R_CheckUserInterrupt utf8/src/as_utf8.c:68
>>    [UP] unprotected variable ans while calling allocating function
>> rutf8_translate_utf8 utf8/src/as_utf8.c:83
>>    [UP] unprotected variable ans while calling allocating function
>> Rf_mkCharLenCE utf8/src/as_utf8.c:117
>>
>> The offending function is at
>> https://github.com/patperry/r-utf8/blob/master/src/as_utf8.c#L46
>>
>> I tried to fix the warning in line 64 with
>>
>> PROTECT(ans = sx); nprot++;
>>
>> This did not work. Any suggestions?
>>
> My hypothesis is that your PROTECT and UNPROTECT calls inside the for
> loop are leaving 'ans' unprotected at some point.  Consider using
> PROTECT_WITH_INDEX() and REPROTECT() instead.
>
>> Thanks,
>>
>>
>> Patrick
>>
>> ______________________________________________
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>
>
>
> Patrick Perry <mailto:ppe...@stern.nyu.edu>
> November 20, 2017 at 9:34 PM
> One of my packages has what I believe to be spurious rchk warnings:
>
> From 
> https://raw.githubusercontent.com/kalibera/cran-checks/master/rchk/results/utf8.out
>  
>
>
> Package utf8 version 1.1.0
> Package built using 73757/R 3.5.0; x86_64-pc-linux-gnu; 2017-11-20 
> 22:02:23 UTC; unix
> Checked with rchk version 63f79d910f5835174fcaa5a0a7d2409348f7d2ac
> More information at 
> https://github.com/kalibera/cran-checks/blob/master/rchk/PROTECT.md
>
> Function rutf8_as_utf8
>   [UP] unprotected variable ans while calling allocating function 
> R_CheckUserInterrupt utf8/src/as_utf8.c:68
>   [UP] unprotected variable ans while calling allocating function 
> rutf8_translate_utf8 utf8/src/as_utf8.c:83
>   [UP] unprotected variable ans while calling allocating function 
> Rf_mkCharLenCE utf8/src/as_utf8.c:117
>
> The offending function is at 
> https://github.com/patperry/r-utf8/blob/master/src/as_utf8.c#L46
>
> I tried to fix the warning in line 64 with
>
> PROTECT(ans = sx); nprot++;
>
> This did not work. Any suggestions?
>
> Thanks,
>
>
> Patrick
>
>


        [[alternative HTML version deleted]]

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to