[Bioc-devel] Strange "internal logical NA value has been modified" error

Martin Morgan mtmorg@n@b|oc @end|ng |rom gm@||@com
Wed Oct 13 12:58:53 CEST 2021


The problem with using gdb is you'd find yourself in the garbage collector, but perhaps quite removed from where the corruption occurred, e.g., gc() might / will likely be triggered after you've returned to the top-level evaluation loop, and the part of your code that did the corruption might be off the stack.

The problem with devtools::check() (and R CMD check) is that running the unit tests occurs in a separate process, so things like setting a global option (and even system variable from within R) may not be visible in the process doing the check. Conversely, for the same reasons, it seems like the problem can be tickled by running the tests alone. So

  R -f <your_source>/tests/testthat.R

would seem to be a good enough starting point.

Actually, I liked Henrik's UBSAN suggestion, which requires the least amount of work. I think I'd then try 

  R -d valgrind -f <your_source>/tests/testthat.R

and then further into the weeds... actually from the section of R-exts you mention

  R_C_BOUNDS_CHECK=yes R -f <your_source>/tests/testthat.R

might also be promising.

Martin

On 10/12/21, 10:30 PM, "Bioc-devel on behalf of Pariksheet Nanda" <bioc-devel-bounces using r-project.org on behalf of pariksheet.nanda using uconn.edu> wrote:

    Hi all,

    On 10/12/21 6:43 PM, Pariksheet Nanda wrote:
    >
    > Error in `...`: internal logical NA value has been modified

    In the R source code, this error is in src/main/memory.c so I was 
    thinking one way of investigating might be to run `R --debugger gdb`, 
    then running R to load the symbols and either:

    1) set a breakpoint for when it reaches that particular line in 
    memory.c:R_gc_internal and then walk up the stack,

    2) or set a watch point on memory.c:R_gc_internal:R_LogicalNAValue 
    (somehow; having trouble getting gdb to reach that context).

    3) Then I thought, maybe this is getting far into the weeds and instead 
    I could check the most common C related error by enabling bounds 
    checking of my C arrays per section 4.4 of the R-exts manual:

    $ R -q
     > options(CBoundsCheck = TRUE)
     > Sys.setenv(R_C_BOUNDS_CHECK = "yes") # Try both ways *shrug*
     > devtools::test()
    ... # All tests still pass.
     > devtools::check()
    ... # No change :(

    Maybe I'm not sure I'm using that option correctly?  Or the option is 
    ignored in devtools::check().  Or indeed, the error is not from over 
    running C array boundaries.

    It turns out that using the precompiled debug symbols[1] isn't all that 
    useful here because I don't get line numbers in gdb without the source 
    files and many symbols are optimized out, so it looks like I would need 
    to compile R from source with -ggdb first instead of using the Debian 
    packages.

    Hopefully this is still the right approach?

    Pariksheet


    [1] After install r-base-core-dbg on Debian for the debug symbols.

    _______________________________________________
    Bioc-devel using r-project.org mailing list
    https://stat.ethz.ch/mailman/listinfo/bioc-devel


More information about the Bioc-devel mailing list