[Rd] withTimeout bug, it does not work properly with nlme anymore

Martin Maechler m@echler @ending from @t@t@m@th@ethz@ch
Wed Aug 8 12:09:24 CEST 2018


>>>>> Martin Maechler 
>>>>>     on Tue, 30 Jan 2018 15:17:50 +0100 writes:

(a bit more than 6 months ago)

>>>>> Ramiro Barrantes <ramiro using precisionbioassay.com>
>>>>>     on Mon, 27 Nov 2017 21:02:52 +0000 writes:

    >> Hello, I was relying on withTimeout (from R.utils) to
    >> help me stop nlme when it �hangs�.  However, recently
    >> this stopped working.  I am pasting a reproducible
    >> example below: withTimeout should stop nlme after 10
    >> seconds but the code will generate data for which nlme
    >> does not converge (or takes too long) and withTimeout
    >> does not stop it.  I tried this both on a linux (64 bit,
    >> CentOS 7, R 3.4.1, nlme 3.1-131 R.util 2.6, and also with
    >> R 3.2.5) and mac (Sierra 10.13.1, R 3.4.2, same versions
    >> or nlme and R.utils).  It takes over R and I need to use
    >> brute-force to stop it.  As mentioned, this used to work
    >> and it is very helpful for the purposes of having a loop
    >> where nlme goes through many models.

    >> Thank you in advance for any help, Ramiro

    > Dear Ramiro,

    > as I thought you are reporting a bug about R.utils
    > withTimeout(), I and maybe others have not reacted.

    > You've addressed this again in a non-public e-mail, and
    > indeed the underlying bug is really in nlme which you do
    > mention implicitly.

    > I'm appending a version of your example that is not using
    > R.utils at all and reproducible hangs for me with R 3.4.3,
    > R 3.4.3 patched and R-devel (and almost surely earlier
    > versions of R which I did not check.

    > Indeed, the call to nlme() "stalls" // "hangs" / "freezes"
    > / ... R indeed, and cannot be terminated in a regular way,
    > and, as you, I do need "brute force" to stop it, killing
    > the R process too.

    > As the maintainer of the 'nlme' *is* R-core, we are asked
    > to fix this, at least making it interruptable.

    > Still I should not take time for that for the next couple
    > of weeks as I should fulfill several other day jobs
    > duties, instead, and so will not promise anything here.

    > Tested (minimal) patches are welcome!

I had forgotten to follow up on this, here.
We did fix this bug in the nlme source code (in the end by simply
replacing old Fortran code in PYTHAG() which looped infinitely when
passed an NAN by a call to C99's hypot()).
This was released with nlme 3.1-137, which is also part of R
3.5.0 an 3.5.1 (and current R development versions).

These examples should now all give an error (about a singular matrix),
instead of hang.

I also had added a regression test for this problem, but
interestingly that test did fail in rare circumstances and hence
it was decided not to be run by default, activated only by an
environment variable setting.
The test *is* part of nlme's sources, and hence also available
directly from
  https://svn.r-project.org/R-packages/trunk/nlme/tests/nlme-stall.R

Best,
Martin Maechler



More information about the R-devel mailing list