[Rd] BUG?: On Linux setTimeLimit() fails to propagate timeout error when it occurs (works on Windows)

Martin Maechler maechler at stat.math.ethz.ch
Wed Oct 26 09:21:35 CEST 2016


>>>>> Spencer Graves <spencer.graves at prodsyse.com>
>>>>>     on Tue, 25 Oct 2016 22:02:29 -0500 writes:

    > On 10/25/2016 9:44 PM, Henrik Bengtsson wrote:
    >> setTimeLimit(elapsed=1) causes a timeout error whenever a call takes
    >> more than one second.  For instance, this is how it works on Windows
    >> (R 3.3.1):
    >> 
    >>> setTimeLimit(elapsed=1)
    >>> Sys.sleep(10); message("done")
    >> Error in Sys.sleep(10) : reached elapsed time limit
    >> 
    >> Also, the error propagates immediately and causes an interrupt after ~1 second;
    >> 
    >>> system.time({ Sys.sleep(10); message("done") })
    >> Error in Sys.sleep(10) : reached elapsed time limit
    >> Timing stopped at: 0.01 0 1.02
    >> 
    >> This works as expected.  However, on Linux (R 3.3.1 but also e.g.
    >> 2.11.0, 2.15.3) I get:
    >> 
    >>> setTimeLimit(elapsed=1)
    >>> system.time({ Sys.sleep(10); message("done") })
    >> Error in Sys.sleep(10) : reached elapsed time limit
    >> Timing stopped at: 0 0 10.01
    >> 
    >> Note how the timeout error is signaled, but for some reason, it does
    >> not interrupt the Sys.sleep(10) call until after it finishes after 10
    >> seconds.  If you change to Sys.sleep(60) it will take 1 minute. Note
    >> that the following print("done") is not called, so the timeout error
    >> does propagate immediately after Sys.sleep() but not before / during.
    >> 
    >> This looks like a bug to me.  Can anyone on macOS confirm whether this
    >> is also a problem there or not?


    >> setTimeLimit(elapsed=1)
    >> system.time({ Sys.sleep(10); message("done") })
    > Error in Sys.sleep(10) : reached elapsed time limit
    > Timing stopped at: 0.003 0.004 0.978
    >> 
    >> sessionInfo()
    > R version 3.3.1 (2016-06-21)
    > Platform: x86_64-apple-darwin13.4.0 (64-bit)
    > Running under: OS X 10.11.6 (El Capitan)

Thank you, Spencer.

Indeed, confirmed here (Linux Fedora 24) for the most current
'R-devel' and "R 3.3.2 RC".

Also, this "not quite terminating" on Linux is not limited to
Sys.sleep() in case someone was wondering:

> setTimeLimit(elapsed=0.5) ; system.time(P <- sfsmisc::primes(1e7))
   user  system elapsed 
  0.227   0.055   0.281 
> str(P)
 int [1:664579] 2 3 5 7 11 13 17 19 23 29 ...
> setTimeLimit(elapsed=0.5) ; system.time(P <- sfsmisc::primes(3e7))
Error in sfsmisc::primes(3e+07) : reached elapsed time limit
Timing stopped at: 0.538 0.132 0.671


This *is* embarrassing a bit;  ..  probably too late to be fixed
for 3.3.2 .. (and something I'd rather leave to others to fix).

It may be that this has never worked on Linux, or then worked in
Linuxen where some interrupt behavior was different.
At least on my current Linux it does not work, all the way back
to R 2.11.1 .. and setTimeLimit() has not existed for much longer...

Martin


    > locale:
    > [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

    > attached base packages:
    > [1] stats     graphics  grDevices utils
    > [5] datasets  methods   base

    > loaded via a namespace (and not attached):
    > [1] rsconnect_0.5 tools_3.3.1
    > Error: reached elapsed time limit

    >> /Henrik
    >> 
    >>> sessionInfo()
    >> R version 3.3.1 (2016-06-21)
    >> Platform: x86_64-w64-mingw32/x64 (64-bit)
    >> Running under: Windows XP x64 (build 2600) Service Pack 3
    >> 
    >>> sessionInfo()
    >> R version 3.3.1 (2016-06-21)
    >> Platform: x86_64-pc-linux-gnu (64-bit)
    >> Running under: Ubuntu 16.04.1 LTS
    >> 
    >>> sessionInfo()
    >> R version 2.11.0 (2010-04-22)
    >> x86_64-unknown-linux-gnu
    >> 
    >> sessionInfo()
    >> R version 2.15.3 (2013-03-01)
    >> Platform: x86_64-unknown-linux-gnu (64-bit)
    >>



More information about the R-devel mailing list