[R-pkg-devel] strange errors (non-ascii symbols) on win-builder R-devel

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Tue Jan 24 20:55:21 CET 2023


On 24/01/2023 1:12 p.m., Ivan Krylov wrote:
> On Tue, 24 Jan 2023 17:33:10 +0000
> Maxim Nazarov <maxim.nazarov using openanalytics.eu> wrote:
> 
>> this seems to come from the C code
> 
> I'm 99% sure this comes from the following changes to the package:
> 
> --- minpack.lm_1.2-2/src/fcn_message.c  2020-03-23 10:54:03.000000000 +0300
> +++ minpack.lm_1.2-3/src/fcn_message.c  2023-01-17 09:30:05.000000000 +0300
> @@ -3,24 +3,24 @@
>   char *fcn_message(char *msg, int info, int n, int nit)
>   {
>       if      (info == 1)
> -        sprintf(msg, "Relative error in the sum of squares is at most `ftol'.");
> +        Rprintf(msg, "Relative error in the sum of squares is at most `ftol'.");
>       else if (info == 2)
> 
> (And so on for other values of `info`.)
> 
> sprintf() takes a string pointer to write into as its first argument.
> Rprintf(), on the other hand, prints straight to the R console; its
> first argument is the format string. Given a valid pointer to an
> uninitialised string instead of the format string, Rprintf prints stack
> garbage to the console, ignoring the following arguments. My guess is
> that the maintainers either intended to remove the msg argument
> altogether or needed to use snprintf() and pass the buffer size to
> fcn_message().
> 

Package maintainers recently got a message telling us not to use 
sprintf() any more.  I guess the minpack.lm maintainer either didn't 
read the whole message carefully enough and used Rprintf as a substitute 
instead of snprintf(), or intended to use snprintf(), but typed 
Rprintf() out of habit.

Duncan Murdoch



More information about the R-package-devel mailing list