From maechler at stat.math.ethz.ch  Tue Jan 30 15:17:50 2018
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 30 Jan 2018 15:17:50 +0100
Subject: [Rd] withTimeout bug,
	it does not work properly with nlme anymore
In-Reply-To: <C7338A7EFF31BB4D831BB06C00887789B9C4AA4D@MBX023-W1-CA-2.exch023.domain.local>
References: <C7338A7EFF31BB4D831BB06C00887789B9C4AA4D@MBX023-W1-CA-2.exch023.domain.local>
Message-ID: <23152.32398.680101.584166@stat.math.ethz.ch>

>>>>> Ramiro Barrantes <ramiro at 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!

Here's a version of your script slightly simplified which
exhibits the problem and shows the problem indeed does not
happen in nlminb() -- which I wrongly assumed for a while --
but indeed in nlme's call to own .C() code.

I am looking into fixing this (making it interruptable // detect
the infinite loop).
My guess is that it only happens in degenerate cases like here.

Martin Maechler
ETH Zurich


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: nlme-stall_Barrantes.R
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20180130/9ab3a760/attachment.ksh>


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