From maechler at stat.math.ethz.ch  Wed Apr  5 09:59:41 2017
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed, 5 Apr 2017 09:59:41 +0200
Subject: [Rd] Very hard to reproduce bug (?) in R-devel
In-Reply-To: <CAFOpNVGO4DEVE+=0Ujysb+zPksyJGA8t1mkB9929wSndJTS0gA@mail.gmail.com>
References: <CAFOpNVFQyz_UtDkuZFxa9ttCcQc6wvN7bDb5AbfsfTT_HuHeog@mail.gmail.com>
 <CAFOpNVG6RtN47SVvg_L1HKYSOPccnXgWjMX3ouLGxjCKXovc=Q@mail.gmail.com>
 <CAFOpNVGO4DEVE+=0Ujysb+zPksyJGA8t1mkB9929wSndJTS0gA@mail.gmail.com>
Message-ID: <22756.41965.160956.187187@stat.math.ethz.ch>

>>>>> Winston Chang <winstonchang1 at gmail.com>
>>>>>     on Tue, 4 Apr 2017 15:29:40 -0500 writes:

    > I've done some more investigation into the problem, and it is very
    > difficult to pin down. What it looks like is happening is roughly like this:
    > - `p` is an environment and `p$e` is also an environment.
    > - There is a loop. In each iteration, it looks for one item in `p$e`, saves
    > it in a variable `x`, then removes that item from `p$e`. Then it invokes
    > `x()`. The loop runs again, until there are no more items in `p$e`.

    > The problem is that `ls(p$e)` sometimes returns the wrong values -- it
    > returns the values that it had in previous iterations of the loop. The
    > behavior is very touchy. Almost any change to the code will slightly change
    > the behavior; sometimes the `ls()` returns values from a different
    > iteration of the loop, and sometimes the problem doesn't happen at all.

    > I've put a  Dockerfile and instructions for reproducing the problem here:
    > https://gist.github.com/wch/2596a1c9f1bcdee91bb210c782141c88

    > I think that I've gotten about as far with this as I can, though I'd be
    > happy to provide more information if anyone wants to take look at the
    > problem.

Dear Winston,

While I agree this may very well be a bug in R(-devel), and hence
also R in 3.4.0 alpha and hence quite important to be dealt with,

your code still involves 3 non-trivial  packages (DBI, R6,
testthat) some of which have their own C code and notably load
a couple of other package's namespaces.
We've always made a point
      https://www.r-project.org/bugs.html
that bugs in R should be reproducible without extra
packages... and I think it would definitely help to pinpoint the
issue to be seen outside of your extra packages' world. 

Or have you been aware of that and are just asking for help
finding a bug in one of the extra packages involved, a bug that might only be triggered by recent changes in R ?

OTOH, what you describe above  (p ; p$e ; p$e$x ...)
should be reproducible in pure "base" R code, right?

I'm sorry not to be of more help
Martin

    > -Winston



[Rd] Very hard to reproduce bug (?) in R-devel
Martin Maechler