[Rd] Difference in NA behavior in R-devel running under valgrind

brodie gaslam brod|e@g@@|@m @end|ng |rom y@hoo@com
Fri Apr 30 02:39:53 CEST 2021


 > On Thursday, April 29, 2021, 6:35:16 PM EDT, Winston Chang <winstonchang1 using gmail.com> wrote:
> Just to be clear, the RD binary that Jon used was NOT compiled with
> Valgrind level 2 instrumentation. In his example, however, he did run it
> with valgrind, as in:
>
> # RD -d valgrind --quiet -e "sum(c(1, NA))"
> ...
> > sum(c(1, NA))
> [1] NaN
>
> `RD` in that Docker image is a standard build of R-devel. The Docker
> image does include a build of R-devel with valgrind level 2
> instrumentation, called `RDvalgrind`. It exhibits the same NaN behavior
> when run with `-d valgrind`, but when run without `-d valgrind` it
> returns NA.
>
> # RDvalgrind -d valgrind --quiet -e "sum(c(1, NA))"
> > sum(c(1, NA))
> [1] NaN
>
> # RDvalgrind --quiet -e "sum(c(1, NA))"
> > sum(c(1, NA))
> [1] NA
>
> In short `RDvalgrind` behaves the same as `RD`. However, adding `-d
> valgrind` to either one causes it to return NaN.
>
> -Winston

Thanks for the clarification.

Using the same revision in the e-mail I get the reported issue under -O0,
but not under -O2.  It looks like r-debug builds with -O0, and presumably
the release debian version is -O2 which is usually the default?  I'm
certainly no expert in this area but it seems like it could be an
optimization level rather than a release vs devel issue?

This is what I see:

gcc version 10.1.0 (Ubuntu 10.1.0-2ubuntu1~18.04)

    CC="gcc-10"
    CFLAGS="-g -O0 -Wall -pedantic -Wextra -std=gnu99"

    vagrant using vagrant:/vagrant/trunk$ ./bin/R -d valgrind --vanilla --quiet -e "sum(c(1,NA))"
    ==9020== Memcheck, a memory error detector
    ==9020== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==9020== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
    ==9020== Command: /vagrant/trunk/bin/exec/R --vanilla --quiet -e sum(c(1,NA))
    ==9020==
    > sum(c(1,NA))
    [1] NaN

And then:

    CC="gcc-10"
    CFLAGS="-g -O2 -Wall -pedantic -Wextra -std=gnu99"

    vagrant using vagrant:/vagrant/trunk$ ./bin/R -d valgrind --vanilla --quiet -e "sum(c(1,NA))"
    ==32751== Memcheck, a memory error detector
    ==32751== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==32751== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
    ==32751== Command: /vagrant/trunk/bin/exec/R --vanilla --quiet -e sum(c(1,NA))
    ==32751==
    > sum(c(1,NA))
    [1] NA

Sadly I did not think to run the -O0 version without valgrind.

Best,

B.



More information about the R-devel mailing list