Coder Social home page Coder Social logo

later's Introduction

later

R build status

Schedule an R function or formula to run after a specified period of time. Similar to JavaScript's setTimeout function. Like JavaScript, R is single-threaded so there's no guarantee that the operation will run exactly at the requested time, only that at least that much time will elapse.

To avoid bugs due to reentrancy, by default, scheduled operations only run when there is no other R code present on the execution stack; i.e., when R is sitting at the top-level prompt. You can force past-due operations to run at a time of your choosing by calling later::run_now().

The mechanism used by this package is inspired by Simon Urbanek's background package and similar code in Rhttpd.

Installation

remotes::install_github("r-lib/later")

Usage from R

Pass a function (in this case, delayed by 5 seconds):

later::later(function() {
  print("Got here!")
}, 5)

Or a formula (in this case, run as soon as control returns to the top-level):

later::later(~print("Got here!"))

Usage from C++

You can also call later::later from C++ code in your own packages, to cause your own C-style functions to be called back. This is safe to call from either the main R thread or a different thread; in both cases, your callback will be invoked from the main R thread.

later::later is accessible from later_api.h and its prototype looks like this:

void later(void (*func)(void*), void* data, double secs)

The first argument is a pointer to a function that takes one void* argument and returns void. The second argument is a void* that will be passed to the function when it's called back. And the third argument is the number of seconds to wait (at a minimum) before invoking.

To use the C++ interface, you'll need to add later to your DESCRIPTION file under both LinkingTo and Imports, and also make sure that your NAMESPACE file has an import(later) entry.

Background tasks

Finally, this package also offers a higher-level C++ helper class to make it easier to execute tasks on a background thread. It is also available from later_api.h and its public/protected interface looks like this:

class BackgroundTask {

public:
  BackgroundTask();
  virtual ~BackgroundTask();

  // Start executing the task
  void begin();

protected:
  // The task to be executed on the background thread.
  // Neither the R runtime nor any R data structures may be
  // touched from the background thread; any values that need
  // to be passed into or out of the Execute method must be
  // included as fields on the Task subclass object.
  virtual void execute() = 0;

  // A short task that runs on the main R thread after the
  // background task has completed. It's safe to access the
  // R runtime and R data structures from here.
  virtual void complete() = 0;
}

Create your own subclass, implementing a custom constructor plus the execute and complete methods.

It's critical that the code in your execute method not mutate any R data structures, call any R code, or cause any R allocations, as it will execute in a background thread where such operations are unsafe. You can, however, perform such operations in the constructor (assuming you perform construction only from the main R thread) and complete method. Pass values between the constructor and methods using fields.

#include <Rcpp.h>
#include <later_api.h>

class MyTask : public later::BackgroundTask {
public:
  MyTask(Rcpp::NumericVector vec) :
    inputVals(Rcpp::as<std::vector<double> >(vec)) {
  }

protected:
  void execute() {
    double sum = 0;
    for (std::vector<double>::const_iterator it = inputVals.begin();
      it != inputVals.end();
      it++) {

      sum += *it;
    }
    result = sum / inputVals.size();
  }

  void complete() {
    Rprintf("Result is %f\n", result);
  }

private:
  std::vector<double> inputVals;
  double result;
};

To run the task, new up your subclass and call begin(), e.g. (new MyTask(vec))->begin(). There's no need to keep track of the pointer; the task object will delete itself when the task is complete.

// [[Rcpp::export]]
void asyncMean(Rcpp::NumericVector data) {
  (new MyTask(data))->begin();
}

It's not very useful to execute tasks on background threads if you can't get access to the results back in R. We'll soon be introducing a complementary R package that provides a suitable "promise" or "future" abstraction.

later's People

Contributors

batpigandme avatar cpsievert avatar jcheng5 avatar jeroen avatar michaelchirico avatar mingwandroid avatar schloerke avatar shikokuchuo avatar tracykteal avatar wch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

later's Issues

Readline warnings

If later callbacks result in errors 11 or more times, then it prints out this warning on the 11th time and each time after:

Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 

I've tested this on Mac and Linux. It happens in a terminal, but not in RStudio.

To reproduce:

for (i in 1:12) {
  local({
    n <- i
    later::later(function() {
      stop("iteration ", n)
    })
  })
}

The result looks like this:

> for (i in 1:12) {
+   local({
+     n <- i
+     later::later(function() {
+       stop("iteration ", n)
+     })
+   })
+ }
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 1.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 2.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 3.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 4.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 5.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 6.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 7.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 8.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 9.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 10.
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 11.
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 
> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: iteration 12.
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 

Or you can simply cut and paste this 11 times:

later::later(function() {
  stop("there was an error")
})

Similar to #25, I wonder if something is not getting cleaned up properly when an exception occurs.

With valgrind, library(later) causes segfault

I've bisected it to 65d21d6.

Here's the output on master:

$ R -d valgrind
... lots of text ...
> library(later)
==12342== Thread 2:
==12342== Invalid read of size 4
==12342==    at 0x1017F8899: _pthread_body (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1017F8886: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1017F808C: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==  Address 0x18 is not stack'd, malloc'd or (recently) free'd
==12342== 
==12342== Invalid read of size 8
==12342==    at 0x1017F69D6: pthread_getspecific (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1001CB5CB: REvprintf (printutils.c:970)
==12342==    by 0x1001C949F: REprintf (printutils.c:856)
==12342==    by 0x10019538A: sigactionSegv (main.c:514)
==12342==    by 0x25805BBB1: ???
==12342==    by 0x1017F8886: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1017F808C: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==  Address 0x50 is not stack'd, malloc'd or (recently) free'd
==12342== 
==12342== 
==12342== Process terminating with default action of signal 11 (SIGSEGV)
==12342==  Access not within mapped region at address 0x50
==12342==    at 0x1017F69D6: pthread_getspecific (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1001CB5CB: REvprintf (printutils.c:970)
==12342==    by 0x1001C949F: REprintf (printutils.c:856)
==12342==    by 0x10019538A: sigactionSegv (main.c:514)
==12342==    by 0x25805BBB1: ???
==12342==    by 0x1017F8886: _pthread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==    by 0x1017F808C: thread_start (in /usr/lib/system/libsystem_pthread.dylib)
==12342==  If you believe this happened as a result of a stack
==12342==  overflow in your program's main thread (unlikely but
==12342==  possible), you can try to increase the size of the
==12342==  main thread stack using the --main-stacksize= flag.
==12342==  The main thread stack size used in this run was 8388608.
--12342:0:schedule VG_(sema_down): read returned -4
==12342== 
==12342== HEAP SUMMARY:
==12342==     in use at exit: 41,389,968 bytes in 19,894 blocks
==12342==   total heap usage: 42,515 allocs, 22,621 frees, 79,637,363 bytes allocated
==12342== 
==12342== LEAK SUMMARY:
==12342==    definitely lost: 1,284 bytes in 20 blocks
==12342==    indirectly lost: 7,426 bytes in 19 blocks
==12342==      possibly lost: 7,888 bytes in 165 blocks
==12342==    still reachable: 40,159,349 bytes in 19,457 blocks
==12342==                       of which reachable via heuristic:
==12342==                         newarray           : 4,264 bytes in 1 blocks
==12342==         suppressed: 1,214,021 bytes in 233 blocks
==12342== Rerun with --leak-check=full to see details of leaked memory
==12342== 
==12342== For counts of detected and suppressed errors, rerun with: -v
==12342== Use --track-origins=yes to see where uninitialised values come from
==12342== ERROR SUMMARY: 33 errors from 8 contexts (suppressed: 25 from 4)
Segmentation fault: 11

Cannot install later on Arch Linux

Hi, I had an error while installing later package on archlinux.

System : Linux NIC-DK02 4.17.11-arch1 #1 SMP PREEMPT Sun Jul 29 10:11:16 UTC 2018 x86_64 GNU/Linux
gcc : 8.2.0

g++ -I"/usr/include/R/" -DNDEBUG -pthread -I"/home/thomas/.R/lib/Rcpp/include" -I"/home/thomas/.R/lib/BH/include" -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c timestamp_win32.cpp -o timestamp_win32.o
gcc -I"/usr/include/R/" -DNDEBUG -pthread -I"/home/thomas/.R/lib/Rcpp/include" -I"/home/thomas/.R/lib/BH/include" -D_FORTIFY_SOURCE=2 -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c tinycthread.c -o tinycthread.o
g++ -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o later.so RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o tinycthread.o -pthread -L/usr/lib64/R/lib -lR
installing to /home/thomas/.R/lib/later/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
sh : ligne 1 : 16090 Abandon (core dumped)'/usr/lib64/R/bin/R' --no-save --slave 2>&1 < '/tmp/RtmpP4GLjS/file3e97172731e7'
terminate called after throwing an instance of 'std::runtime_error'
what(): Mutex creation failed
ERROR: loading failed

Here is the sessioninfo:

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS: /usr/lib/libblas.so.3.8.0
LAPACK: /usr/lib/liblapack.so.3.8.0

locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8
[7] LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 tcltk_3.5.1

run_now: high CPU usage on Linux

When I run this, it consumes 66% of my CPU on Linux.

library(later)
while(1) run_now(1)

On my Mac, it uses ~0%. (I haven't tested on Windows.)

Interruption of callbacks can result in `c++ exception (unknown reason)` message

Downstream issues:
rstudio/shiny#1967 (comment)
rstudio/httpuv#130


This happens only under certain circumstances, when a native/Rcpp callback function is registered with the native later::later API, and an interrupt occurs within the callback.

Rcpp::cppFunction(depends = "later",
  code = '
  void test() {
    later::later(doIt, 0, 0);
  }
  ',
  includes = '
  #include <later_api.h>

  void doIt(void* data) {
    throw new Rcpp::internal::InterruptedException();
  }
  ')

Run test() to reproduce; you should see later: c++ exception (unknown reason) occurred while executing callback.

In the example above, we are calling throw Rcpp::internal::InterruptedException() explicitly, but it can happen through user gesture as well:

Rcpp::cppFunction(depends = "later",
  code = '
  void test2() {
    later::later(doIt, 0, 0);
  }
  ',
  includes = '
  #include <later_api.h>

  void doIt(void* data) {
    Rcpp::Function func("Sys.sleep");
    func(5);
  }
  ')

Run test2(); later::run_now(5), and quickly hit Esc or Ctrl+C to interrupt. You should see Error in execCallbacks(timeoutSecs) : c++ exception (unknown reason).

The root cause seems to have to do with the compilation unit of the throw Rcpp::internal::InterruptedException versus that of the catch (Rcpp::internal::InterruptedException) (usually the latter is via the END_RCPP macro). A minimal repro for this problem is at https://github.com/jcheng5/exceptiontest.

Quitting from debugger causes later to stop working

This is almost the same as #12, but instead of a stop(), it happens when quitting the debugger.

library(later)
later(function() {
  cat("1\n", file=stderr())
  browser()    # Q out of this
  cat("2\n", file=stderr())
})


# No longer works
later(function() {
  cat("hello\n", file=stderr())
})

The root cause is RcppCore/Rcpp#754.

We need to make sure that using the debugger doesn't break later and therefore require restarting the R process.

later with Rscript

I have a problem with later in Rscript.
Without later I get result printed

$ Rscript -e 'print("Got here!")'
[1] "Got here!"
$

With later code executed in a moment and nothing printed

$ Rscript -e 'later::later( function() { print("Got here!") }, 5 )'
$

I am on ubuntu 16.04 and R version 3.4.4. And would love to use later with RScript to automate my script execution and hope to get an advice on how to do it. Thank you.
Installation log:

>devtools::install_github( 'r-lib/later' )
Downloading GitHub repo r-lib/later@master
from URL https://api.github.com/repos/r-lib/later/zipball/master
Installing later
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
  CMD INSTALL '/tmp/RtmpBWNDXU/devtools3be73f35c781/r-lib-later-11bd19f'  \
  --library='/home/stanislav/R/x86_64-pc-linux-gnu-library/3.4'  \
  --install-tests 

* installing *source* package ‘later’ ...
Running configure script
Using CC=gcc -std=gnu99
Using CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g
Using CPPFLAGS=
C11-style threads.h support not detected. Using tinycthread library.
** libs
...

WebSocket run with later private loop can sometimes not be GC'd

Note: this needs the joe/feature/private-event-loops2 branch branch of later.

In this example, the websocket is created and closed, and driven from a private event loop. It calls run_now() until the websocket's has readyState()==3. If the ws object is removed and then a GC happens, the object is not garbage collected. The event loop needs to be run one more time before the GC occurs.

devtools::install_github("r-lib/later@joe/feature/private-event-loops2")

library(later)
library(WebSocket)

private_loop <- NULL
later::with_private_loop({
  private_loop <<- current_loop()
  ws <- WebSocket$new("ws://echo.websocket.org")
  reg.finalizer(ws, function(e) message("finalized!"))
  ws$close()
  while (ws$readyState() != 3L) {
    run_now()
  }
})

rm(ws)
gc()
#>           used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells  967903 51.7    1538886 82.2         NA  1538886 82.2
#> Vcells 2165223 16.6    8388608 64.0      16384  4722708 36.1

run_now(loop = private_loop)
gc()
#> finalized!
#>           used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
#> Ncells  967903 51.7    1538886 82.2         NA  1538886 82.2
#> Vcells 2165394 16.6    8388608 64.0      16384  4722708 36.1

This happens because scheduleIncoming() is always called right after wsPoll(), even if that wsPoll() call changes the readyState to 3:

https://github.com/rstudio/websocket/blob/ccc03d59868b3ced956d54bd22dc4e89376dd207/R/websocket.R#L240-L247

Interrupt or error during callback causes terminal to not echo output

If you run this code in a terminal, then press Ctrl-C before it finishes, then quit R, the terminal will no longer echo text that is typed. Running reset restores it to normal.

R
library(later)

later(function() {
  cat("start...")
  Sys.sleep(5)
  cat("done.\n")
})

However, catching the interrupt prevents the problem:

R
library(later)

later(function() {
  cat("start...")
  tryCatch({
    Sys.sleep(5)
  }, 
  interrupt = function(e) {
    cat("interrupt")
  })
  cat("done.\n")
})

Some more information about this type of problem: https://askubuntu.com/a/172747/131896

In itself, this isn't a big problem, but it makes me wonder if other things are not being cleaned up properly.

> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.4.2 (2017-09-28)
 os       macOS High Sierra 10.13.1   
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2017-11-21                  

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version    date       source                      
 clisymbols    1.2.0      2017-05-21 CRAN (R 3.4.0)              
 later       * 0.6.0.9000 2017-11-21 Github (r-lib/later@c1c3b09)
 Rcpp          0.12.13    2017-09-28 cran (@0.12.13)             
 sessioninfo   1.0.0      2017-06-21 CRAN (R 3.4.1)              
 withr         2.1.0      2017-11-01 CRAN (R 3.4.2)              

Cannot install later on Ubuntu 16.04

Hi, during installation of shiny, I found out that the installation breaks on the installation of later package.

System: Azure VM with Ubuntu 16.04
R version 3.4.4 (2018-03-15) x86_64-pc-linux-gnu

Steps to reproduce: Installing later package on fresh Ubuntu VM from Azure.

> install.packages('later')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/later_0.7.3.tar.gz'
Content type 'application/x-gzip' length 38192 bytes (37 KB)
==================================================
downloaded 37 KB

* installing *source* package ‘later’ ...
** package ‘later’ successfully unpacked and MD5 sums checked
** libs
g++  -I/usr/share/R/include -DNDEBUG -pthread -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:0:
../inst/include/later.h:6:18: fatal error: Rcpp.h: No such file or directory
compilation terminated.
/usr/lib/R/etc/Makeconf:168: recipe for target 'RcppExports.o' failed
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘later’
* removing ‘/usr/local/lib/R/site-library/later’
Warning in install.packages :
  installation of package ‘later’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpIM80D3/downloaded_packages’

Session info:

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4  

This is similar to #62, however installing from github does not solve my issue.

later() c++ interface should accept something like boost::function0<void>

The Callback class stores a boost::function0<void> object, but it can be passed a Rcpp::Function object, as is done here:
https://github.com/r-lib/later/blob/c1c3b09/src/callback_registry.cpp#L9

This suggests that it might be possible to allow users to pass in some sort of generic function-like object, without requiring them to use boost.

If that doesn't work, we could supply a pure virtual class that others could implement. For example, on a branch of httpuv, there's a Callback class:

class Callback {
public:
  virtual ~Callback() {};
  virtual void operator()() = 0;
};

And here is an implementation that takes boost::function objects:

#include <boost/function.hpp>

// Wrapper class for boost functions
class BoostFunctionCallback : public Callback {
private:
  boost::function<void (void)> fun;

public:
  BoostFunctionCallback(boost::function<void (void)> fun)
    : fun(fun) {
  }

  void operator()() {
    fun();
  }
};

Warn/error when callbacks call run_now()?

Currently it's possible for a callback to call run_now(). Perhaps later should warn/error when this happens? This is related to rstudio/httpuv#148.

In this example, the second run_now() makes the callbacks run, but the same thing happens if that's removed and the execution of callbacks is triggered by R's input handler.

library(later)
{
  later(function() {
    cat("1")
    later(function() cat("2"))
    cat("3")
    run_now()
    cat("4")
  })
  cat("5")
  run_now()
  cat("6")
}
#> 513246

Install error

When I install this package I get this error.

Error Msg.
Downloading GitHub repo r-lib/later@master
   checking for file 'C:\Users\lijiaxiang\AppData\Local\Temp\RtmpQJuRLe\remotes39ac1ad560b5\r-lib-later-55f63f3/DESCRIPTION' ...√checking for file 'C:\Users\lijiaxiang\AppData\Local\Temp\RtmpQJuRLe\remotes39ac1ad560b5\r-lib-later-55f63f3/DESCRIPTION' (546ms)ax global extended headers  
-  preparing 'later': (419ms)
√  checking DESCRIPTION meta-information ... 
-  cleaning src
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'later_0.8.0.9000.tar.gz'
   
Installing package into ��C:/Users/lijiaxiang/Documents/R/win-library/3.5��
(as ��lib�� is unspecified)
* installing *source* package 'later' ...
** libs

*** arch - i386
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c callback_registry.cpp -o callback_registry.o
C:/RBuildTools/3.5/mingw_32/bin/gcc  -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O3 -Wall  -std=gnu99 -mtune=generic -c init.c -o init.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later.cpp -o later.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_native.cpp -o later_native.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_posix.cpp -o later_posix.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_win32.cpp -o later_win32.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timer_posix.cpp -o timer_posix.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timestamp_unix.cpp -o timestamp_unix.o
C:/RBuildTools/3.5/mingw_32/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timestamp_win32.cpp -o timestamp_win32.o
C:/RBuildTools/3.5/mingw_32/bin/gcc  -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O3 -Wall  -std=gnu99 -mtune=generic -c tinycthread.c -o tinycthread.o
C:/RBuildTools/3.5/mingw_32/bin/g++ -shared -s -static-libgcc -o later.dll tmp.def RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o tinycthread.o -pthread -LC:/PROGRA~1/R/R-35~1.2/bin/i386 -lR
installing to C:/Users/lijiaxiang/Documents/R/win-library/3.5/later/libs/i386

*** arch - x64
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c RcppExports.cpp -o RcppExports.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c callback_registry.cpp -o callback_registry.o
C:/RBuildTools/3.5/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -std=gnu99 -mtune=generic -c init.c -o init.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later.cpp -o later.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_native.cpp -o later_native.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_posix.cpp -o later_posix.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c later_win32.cpp -o later_win32.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timer_posix.cpp -o timer_posix.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timestamp_unix.cpp -o timestamp_unix.o
C:/RBuildTools/3.5/mingw_64/bin/g++  -std=gnu++11 -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -mtune=generic -c timestamp_win32.cpp -o timestamp_win32.o
C:/RBuildTools/3.5/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-35~1.2/include" -DNDEBUG -pthread -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/Rcpp/include" -I"C:/Users/lijiaxiang/Documents/R/win-library/3.5/BH/include"        -O2 -Wall  -std=gnu99 -mtune=generic -c tinycthread.c -o tinycthread.o
C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o later.dll tmp.def RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o tinycthread.o -pthread -LC:/PROGRA~1/R/R-35~1.2/bin/x64 -lR
installing to C:/Users/lijiaxiang/Documents/R/win-library/3.5/later/libs/x64
Error in file.copy(files, dest, overwrite = TRUE) : 
  (由警告转换成)拷贝.\later.dll到C:\Users\lijiaxiang\Documents\R\win-library\3.5\later\libs\x64\later.dll时出了问题:Permission denied 
* removing 'C:/Users/lijiaxiang/Documents/R/win-library/3.5/later'
* restoring previous 'C:/Users/lijiaxiang/Documents/R/win-library/3.5/later'
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) : 
  (由警告转换成)拷贝C:\Users\lijiaxiang\Documents\R\win-library\3.5\00LOCK-later\later\libs\x64\later.dll到C:\Users\lijiaxiang\Documents\R\win-library\3.5\later\libs\x64\later.dll时出了问题:Permission denied 
停止执行
In R CMD INSTALL
installation of package ��C:/Users/LIJIAX~1/AppData/Local/Temp/RtmpQJuRLe/file39ac615d550a/later_0.8.0.9000.tar.gz�� had non-zero exit status

Thus, I cannot library this package.

library(later)
#> Error in library(later): 'later'不是有效的已经安装了的程序包

Created on 2019-02-15 by the reprex package (v0.2.1)

However, I can use it in some way.

> later::later(function() {
+   print("Got here!")
+ }, 5)
[1] "Got here!"

I think it is a bug.

Here is my session info.

> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936   
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                   
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

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

other attached packages:
 [1] reprex_0.2.1    bindrcpp_0.2.2  lubridate_1.7.4 forcats_0.3.0   stringr_1.3.1   dplyr_0.7.8     purrr_0.2.5    
 [8] readr_1.3.1     tidyr_0.8.2     tibble_2.0.1    ggplot2_3.1.0   tidyverse_1.2.1

loaded via a namespace (and not attached):
 [1] nlme_3.1-137          fs_1.2.6              usethis_1.4.0         devtools_2.0.1        RColorBrewer_1.1-2   
 [6] httr_1.4.0            rprojroot_1.3-2       data.tree_0.7.8       tools_3.5.2           backports_1.1.3      
[11] R6_2.3.0              rebus.base_0.0-3      lazyeval_0.2.1        colorspace_1.3-2      withr_2.1.2          
[16] tidyselect_0.2.5      gridExtra_2.3         prettyunits_1.0.2     processx_3.2.1        curl_3.2             
[21] compiler_3.5.2        git2r_0.23.0          cli_1.0.1             rvest_0.3.2           xml2_1.2.0           
[26] influenceR_0.1.0      desc_1.2.0            bookdown_0.9          scales_1.0.0          callr_3.1.1          
[31] digest_0.6.18         rebus.unicode_0.0-2   rmarkdown_1.11        pkgconfig_2.0.2       htmltools_0.3.6      
[36] sessioninfo_1.1.1     htmlwidgets_1.3       rlang_0.3.1           readxl_1.2.0          rstudioapi_0.9.0     
[41] bindr_0.1.1           visNetwork_2.0.5      generics_0.0.2        jsonlite_1.6          rgexf_0.15.3         
[46] magrittr_1.5          Matrix_1.2-15         Rcpp_1.0.0            munsell_0.5.0         clipr_0.4.1          
[51] viridis_0.5.1         whisker_0.3-2         stringi_1.2.4         add2md_0.10.2         yaml_2.2.0           
[56] pkgbuild_1.0.2        plyr_1.8.4            grid_3.5.2            crayon_1.3.4          rebus.datetimes_0.0-1
[61] lattice_0.20-38       haven_2.0.0           hms_0.4.2             knitr_1.21            ps_1.3.0             
[66] pillar_1.3.1          igraph_1.2.2          rebus.numbers_0.0-1   xgboost_0.71.2        pkgload_1.0.2        
[71] rebus_0.1-3           XML_3.98-1.16         glue_1.3.0            packrat_0.5.0         evaluate_0.12        
[76] downloader_0.4        data.table_1.11.8     remotes_2.0.2         modelr_0.1.2          testthat_2.0.1       
[81] cellranger_1.1.0      gtable_0.2.0          assertthat_0.2.0      xfun_0.4              broom_0.5.1          
[86] later_0.7.5           rsconnect_0.8.12      viridisLite_0.3.0     memoise_1.1.0         Rook_1.1-1           
[91] DiagrammeR_1.0.0      brew_1.0-6           

Load error on Fedora 29: Mutex creation failed

This is a followup to #63.

A Dockerfile that installs Anaconda and R on Fedora 29:

FROM fedora:latest

RUN dnf install -y 'dnf-command(builddep)'
RUN dnf install -y wget bzip2

RUN wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
RUN bash ./Anaconda3-5.2.0-Linux-x86_64.sh -b
ENV PATH /root/anaconda3/bin:$PATH
RUN conda install r-base=3.5.1 r-essentials

CMD /bin/bash

To build the image and run the container, enter the directory with the Dockerfile and run:

docker build -t fr .
docker run --rm -ti fr /bin/bash

Inside the container, run:

R
options(repos=c(CRAN="https://cloud.r-project.org/"))
install.packages("later")

Some of the output:

> install.packages("later")
trying URL 'https://cloud.r-project.org/src/contrib/later_0.7.5.tar.gz'
Content type 'application/x-gzip' length 38900 bytes (37 KB)
==================================================
downloaded 37 KB

* installing *source* package ‘later’ ...
** package ‘later’ successfully unpacked and MD5 sums checked
Running configure script
Using CC=x86_64-conda_cos6-linux-gnu-cc
Using CFLAGS=-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -I/root/anaconda3/include -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix
Using CPPFLAGS=-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -I/root/anaconda3/include -Wl,-rpath-link,/root/anaconda3/lib
C11-style threads.h support not detected. Using tinycthread library.
...
...
...
x86_64-conda_cos6-linux-gnu-c++ -shared -L/root/anaconda3/lib/R/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,-rpath,/root/anaconda3/lib -L/root/anaconda3/lib -Wl,-rpath-link,/root/anaconda3/lib -o later.so RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o -pthread ./tinycthread/tinycthread.o -L/root/anaconda3/lib/R/lib -lR
installing to /root/anaconda3/lib/R/library/later/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
sh: line 1:   387 Aborted                 (core dumped) '/root/anaconda3/lib/R/bin/R' --no-save --slave 2>&1 < '/tmp/RtmpkPZJXx/file10cd09078'
terminate called after throwing an instance of 'std::runtime_error'
  what():  Mutex creation failed
ERROR: loading failed
* removing ‘/root/anaconda3/lib/R/library/later’
* restoring previous ‘/root/anaconda3/lib/R/library/later’

The downloaded source packages are in
	‘/tmp/RtmpSEDqty/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("later") :
  installation of package ‘later’ had non-zero exit status

Using C++ interface for later::later() can trigger R's GC on the wrong thread

This is a bug that @jcheng5 and I have been tracking down. Here's an example that will crash R most of the time on Mac and Linux :

# Requires background-thread branch of httpuv
# devtools::install_github("rstudio/httpuv@background-thread")

library(promises)
promise(~later::later(~resolve(NULL), 5)) %...>% { message("Done") }

app <- list(
  call = function(req) {
    list(
      status = 200L,
      headers = list(
        "Content-Type" = "text/plain"
      ),
      body = "Hello"
    )
  }
)

httpuv::startServer("0.0.0.0", 8000, app)
# Must open a web browser to http://127.0.0.1:8000 and reload before "Done" is printed

This will crash with weird errors like

Error in tryCatch(evalq((function (hash = TRUE, parent = parent.frame(),  : 
  object 'classes' not found

and

Error in !missing(finally) : 179 arguments passed to '!' which requires 1

Using the special builds of R, RDsan and RDassertthread from https://github.com/wch/r-debug, I found that the cause of these weird errors is an R GC event occurring on the wrong thread. The GC is triggered when the background thread (as opposed to the main R thread) calls the C++ function later::later(), and schedules a C function to be run. This can cause the std::priority_queue<Callback> in later::CallbackRegistry to reorganize itself, which can cause the Rcpp::Function to be copied, which can trigger a GC on the wrong thread.

This can be see in the stack trace here:
https://gist.github.com/wch/1705437725df17e16e412946143c0d88#file-gistfile2-txt-L21-L60

With RDassertthread, it crashes every time, with:

R: memory.c:3325: R_PreserveObject: Assertion `pthread_equal(pthread_self(), __R_thread_id__)' failed.
Aborted

Using RDassertthread -d gdb provides a stack trace.

Interrupt in callback in RStudio on Windows can cause callback to run a second time

When a later callback is executed in R in a terminal (Mac/Linux) or in RGui (Windows), pressing Ctrl-C or Esc will interrupt that callback. However, on Windows, the interrupt can cause the callback to run a second time.

Here is a spin loop. (I'm using this instead of Sys.sleep() because the way that RStudio on Windows handles interrupts for Sys.sleep() seems to have a delay):

spin <- function(n) {
  cat("start... ")
  start <- as.numeric(Sys.time())
  while (as.numeric(Sys.time()) < start + n) NULL
  cat("end")
}

If you run this in RStudio, R-terminal, or RGui and then pres Ctrl-C/Esc, it will interrupt the loop and put you back at the prompt:

> spin(5)
start...
>

However, if you run this via a later callback, the behavior differs:

later::later(function() spin(5))

On R-terminal (Mac/Linux) and RGui (Windows), it does:

> later::later(function() spin(5))
start... later: interrupt occurred while executing callback.
>

In RStudio on Mac (1.2.761), pressing Esc seems to not interrupt the code. It will look like this. RStudio prints the second > after the end is printed, which suggests it's holding all the interrupts until after the callback finishes:

> later::later(function() spin(5))
start... end>

>

In RStudio on Windows (1.2.710), pressing Esc also does not interrupt the code, but it also causes it to run a second time. This is what it looks like:

> later::later(function() spin(3))
start... end> 

start... end
>

Pressing Esc when it runs a second time does not cause it to run a third time.


Note that if the callbacks are executed with later::run_now(), the behavior is different, and makes more sense in general. On all the platforms mentioned, pressing Esc simply stops the callback after it prints start.... It does not print later: interrupt occurred while executing callback, and it does not run the callback a second time.

Condition variable failed to timedwait

Ran cran_explorer app, async-demo2 branch. Hit the "Refresh Data" button, then turned off wifi. Waited a couple of minutes for the download to error (which it never did). While waiting, I slightly edited the file in RStudio and hit Save. Immediately got this error in the console:

Error in execCallbacks(timeoutSecs) : 
  Condition variable failed to timedwait

Server is unresponsive now; it doesn't refuse connections, but doesn't respond either.

Session info:

Session info -----------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.0 (2017-04-21)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.2.234)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2018-02-02                  

Packages ---------------------------------------------------------------------------------------------
 package      * version    date       source                            
 assertthat     0.2.0      2017-04-11 CRAN (R 3.4.0)                    
 bindr          0.1        2016-11-13 CRAN (R 3.4.0)                    
 bindrcpp     * 0.2        2017-06-17 CRAN (R 3.4.0)                    
 codetools      0.2-15     2016-10-05 CRAN (R 3.4.0)                    
 colorspace     1.3-2      2016-12-14 CRAN (R 3.4.0)                    
 crayon         1.3.4      2017-09-16 CRAN (R 3.4.1)                    
 devtools       1.12.0     2016-12-05 CRAN (R 3.4.0)                    
 digest         0.6.15     2018-01-28 CRAN (R 3.4.0)                    
 dplyr        * 0.7.4      2017-09-28 CRAN (R 3.4.2)                    
 future       * 1.6.2      2017-10-16 CRAN (R 3.4.2)                    
 ggplot2      * 2.2.1      2016-12-30 CRAN (R 3.4.0)                    
 ggrepel      * 0.7.0      2017-09-29 CRAN (R 3.4.2)                    
 globals        0.11.0     2018-01-10 CRAN (R 3.4.3)                    
 glue           1.2.0      2017-10-29 CRAN (R 3.4.2)                    
 gtable         0.2.0      2016-02-26 CRAN (R 3.4.0)                    
 hms            0.4.0      2017-11-23 CRAN (R 3.4.3)                    
 htmltools      0.3.6.9000 2018-01-24 Github (rstudio/htmltools@76661e3)
 httpuv         1.3.5.9005 2018-02-02 Github (rstudio/httpuv@43181b1)   
 jsonlite       1.5        2017-06-01 CRAN (R 3.4.0)                    
 later          0.7.1      2018-02-02 Github (r-lib/later@35b0bae)      
 lazyeval       0.2.1.9000 2018-01-10 Github (hadley/lazyeval@93c455c)  
 listenv        0.7.0      2018-01-21 cran (@0.7.0)                     
 magrittr       1.5        2014-11-22 CRAN (R 3.4.0)                    
 memoise        1.1.0      2017-04-21 CRAN (R 3.4.0)                    
 mime           0.5        2016-07-07 CRAN (R 3.4.0)                    
 munsell        0.4.3      2016-02-13 CRAN (R 3.4.0)                    
 pillar         1.1.0      2018-01-14 cran (@1.1.0)                     
 pkgconfig      2.0.1      2017-03-21 CRAN (R 3.4.0)                    
 plyr           1.8.4      2016-06-08 CRAN (R 3.4.0)                    
 promises     * 0.1.0.9001 2018-02-02 Github (rstudio/promises@1597b8c) 
 purrr        * 0.2.4      2017-10-18 CRAN (R 3.4.2)                    
 R6             2.2.2      2017-06-17 cran (@2.2.2)                     
 RColorBrewer   1.1-2      2014-12-07 CRAN (R 3.4.0)                    
 Rcpp           0.12.15    2018-01-20 CRAN (R 3.4.3)                    
 readr        * 1.1.1      2017-05-16 CRAN (R 3.4.0)                    
 rlang          0.1.6.9003 2018-01-24 Github (tidyverse/rlang@7b02a61)  
 rstudioapi     0.7        2017-09-07 cran (@0.7)                       
 scales         0.5.0      2017-08-24 CRAN (R 3.4.1)                    
 shiny        * 1.0.5.9000 2018-02-02 Github (rstudio/shiny@a76a066)    
 shinythemes  * 1.1.1      2016-10-12 CRAN (R 3.4.0)                    
 tibble         1.4.2      2018-01-22 cran (@1.4.2)                     
 tidyr        * 0.7.2      2017-10-16 CRAN (R 3.4.2)                    
 tidyselect     0.2.0      2017-08-30 CRAN (R 3.4.1)                    
 withr          2.1.1      2017-12-19 CRAN (R 3.4.3)                    
 xtable         1.8-2      2016-02-05 CRAN (R 3.4.0)                    
 yaml           2.1.16     2017-12-12 CRAN (R 3.4.3)                    

Feature request: add option to add callback at front of queue

Rprintf and REprintf are not thread-safe, and R CMD check doesn't like it when C code uses stdout or stderr. This means that, in order for a background thread to print messages to the console, it needs to send a message to the main thread.

It would be useful to schedule message-printing callbacks at the front of the queue, so they happen before any other scheduled callbacks.

later installation stops at the "testing if installed package can be loaded" step

Dear all,

I have an issue when trying to install later with R 3.4.1 and a Fedora 25. The installation process stops at the ** testing if installed package can be loaded. I have then to kill the R session... Note that the a directory 00LOCK-later/ is present afterward in the R library path.

Erwan

Please find below the installation session and the corresponding session info.

> install.packages("later")
Installing package into ‘/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/later_0.4.tar.gz'
Content type 'application/x-gzip' length 31470 bytes (30 KB)
==================================================
downloaded 30 KB

* installing *source* package ‘later’ ...
** package ‘later’ successfully unpacked and MD5 sums checked
** libs
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c RcppExports.cpp -o RcppExports.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c callback_registry.cpp -o callback_registry.o
gcc -m64 -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c init.c -o init.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c later.cpp -o later.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c later_native.cpp -o later_native.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c later_posix.cpp -o later_posix.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c later_win32.cpp -o later_win32.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c timer_posix.cpp -o timer_posix.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c timestamp_unix.cpp -o timestamp_unix.o
g++ -m64  -I/usr/include/R -DNDEBUG -pthread -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/Rcpp/include" -I"/home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/BH/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic  -c timestamp_win32.cpp -o timestamp_win32.o
g++ -m64 -shared -L/usr/lib64/R/lib -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -o later.so RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o -pthread -L/usr/lib64/R/lib -lR
installing to /home/lepennec/R/x86_64-redhat-linux-gnu-library/3.4/later/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
  converting help for package ‘later’
    finding HTML links ... done
    later                                   html  
    loop_empty                              html  
    run_now                                 html  
Rd warning: /tmp/RtmpY3O5AJ/R.INSTALL42493fd5128d/later/man/run_now.Rd:22: missing file link ‘tryCatch’
** building package indices
** installing vignettes
** testing if installed package can be loaded
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 26 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1 tools_3.4.1    yaml_2.1.14   
> 

options(error=recover) doesn't work with later callbacks

options(error=recover) doesn't work when an error occurs in a callback invoked by later. This probably isn't fixable in later, but later should at least have more helpful error messages and documentation on how to deal with this.

An example with execCallbacks being called from the R input handler:

f <- function() {
  stop("error here!")
}

options(error = recover)
later::later(f)

It just prints this, and doesn't go into a debugger prompt:

later: exception occurred while executing callback: 
Evaluation error: error here!.

If it's triggered from run_now(), you get the frame selector, but the top level frame you can access is execCalllbacks() -- you can't get to the function where the error was actually thrown. Example:

f <- function() {
  stop("error here!")
}

options(error = recover)

local({
  later::later(f)
  later::run_now()
})

The output:

> local({
+   later::later(f)
+   later::run_now()
+ })
Error in execCallbacks(timeoutSecs) : Evaluation error: error here!.

Enter a frame number, or 0 to exit   

1: local({
    later::later(f)
    later::run_now()
})
2: eval.parent(substitute(eval(quote(expr), envir)))
3: eval(expr, p)
4: eval(expr, p)
5: eval(quote({
    later::later(f)
    later::run_now()
}), new.env())
6: eval(quote({
    later::later(f)
    later::run_now()
}), new.env())
7: #3: later::run_now()
8: execCallbacks(timeoutSecs)

Selection: 

Compilation failed on linux (el7) during installation of Shiny Server

While attempting to install Shiny Server using this command from the instructions:
sudo su -
-c "R -e "install.packages('shiny', repos='https://cran.rstudio.com/')\""

The compilation of 'later' package fails. This seems to be the pertinent part of the output:

In file included from /usr/lib64/R/library/Rcpp/include/Rcpp.h:77:0,
from ../inst/include/later.h:6,
from RcppExports.cpp:4:
/usr/lib64/R/library/Rcpp/include/Rcpp/Rmath.h: In function ‘double R::pythag(double, double)’:
/usr/lib64/R/library/Rcpp/include/Rcpp/Rmath.h:222:55: error: ‘::Rf_pythag’ has not been declared
inline double pythag(double a, double b) { return ::Rf_pythag(a, b); }
^
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘later’

Since this is linux, I cannot install a binary version of the package (can I?), so I am stuck, and cannot install Shiny Server.

Linker warning: argument unused during compilation: '-pthread'

When I build the package, I get:

clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o later.so RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o -pthread -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]

Having this for the Makevars file seems to make it go away (but I don't know if it's correct):

PKG_CPPFLAGS = -pthread
PKG_LIBS = -lpthread

RNG state not preserved in callbacks

The RNG state is not always preserved when executing callbacks. This is similar to rstudio/shiny#1768.

This example sets the value of .Random.seed in a callback, but it appears to not have an effect:

{
  set.seed(100)
  oldseed <- .GlobalEnv$.Random.seed
  set.seed(1234)

  later(function() {
    .GlobalEnv$.Random.seed <- oldseed
  })
  run_now()
}
identical(oldseed, .GlobalEnv$.Random.seed)
# [1] FALSE

If you call httpuv::getRNGState() in the callback, it fixes the problem. (That function was added to deal with problems just like this).

{
  set.seed(100)
  oldseed <- .GlobalEnv$.Random.seed
  set.seed(1234)

  later(function() {
    .GlobalEnv$.Random.seed <- oldseed
    httpuv::getRNGState()
  })
  run_now()
}
identical(oldseed, .GlobalEnv$.Random.seed)
# [1] TRUE

When this is fixed, we also need to make sure that it fixes it when the input handler executes the callback. To test it, run this at the console. Just run the first part, wait for a moment, and then run the last line.

set.seed(100)
oldseed <- .GlobalEnv$.Random.seed
set.seed(1234)

later(function() {
  .GlobalEnv$.Random.seed <- oldseed
})

# Wait for a moment before running this
identical(oldseed, .GlobalEnv$.Random.seed)

Evaluation error: attempt to apply non-function.

Thus far I cannot reproduce this in a minimal example. So instead I offer a brief error report and request guidance. Maybe this is a known problem? Or my error can be recognized by sharper eyes than mine? For what it's worth, I use later(f, delay) successfully at several other points in my shiny app.

Context:

  1. shiny 1.1.0, R 3.5.1, later 0.7.3.9000, macos
  2. in my server function
  3. within observeEvent(input$addTrack, {
  4. myFunc <- function() loadBedGraphTrack(trackName, tbl.dhs)
  5. myFunc() # works
  6. later(myFunc, delay=1) fails
Error in execCallbacks(timeoutSecs) : 
  Evaluation error: attempt to apply non-function.

Any suggestions?

  • Paul

Compilation failing under Manjaro linux

Hi, I'm trying to install later from CRAN (I also tried the development version), but I keep running into an error when compiling the package. The failing call looks like this:

g++ -I"/usr/include/R/" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=1 -I"/home/karpfen/R/lib/Rcpp/include" -I"/home/karpfen/R/lib/BH/include" -D_FORTIFY_SOURCE=2 -fopenmp -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c timestamp_win32.cpp -o timestamp_win32.o

Error message: make: *** No rule to make target '-fopenmp', needed by 'later.so'. Stop.

Relevant software info:

  • Linux version 4.14.74-1-MANJARO
  • Distribution: Manjaro Linux 18.0.0-rc
  • R: 3.5.1
  • g++: g++ (GCC) 8.2.1 20180831

Anything I could be doing wrong here?
Thanks for your help!

Release checklist v0.8.0

  • Create a GitHub issue for release checklist
  • Create branch labelled v0.8.0-rc
  • Change the DESCRIPTION and NEWS on this branch to change the version number to the desired version for CRAN
  • Commit and push to the RC branch.
  • Clean your package directory to remove any extraneous files, including ones that are git-ignored. (Warning, this will delete any unsaved buffers in RStudio! Also, be sure to close RStudio before taking this step!) git clean -xdf .
  • Build your package. I (jcheng) personally do it from the Mac command line like this:
    PATH=$PATH:/Applications/RStudio.app/Contents/MacOS/pandoc R CMD build [pkgdir]
  • Do a sanity check by installing/testing the built package.
  • Run R CMD check --as-cran pkg_version.tar.gz both locally and on win-builder. You can also use https://r-hub.github.io/rhub/.
  • Read every bullet point in the CRAN Policies document if this is the first release of the package. I usually print it out and check off the items one by one.
  • Submit to CRAN via their online form.
  • If there are R CMD check warnings that are unavoidable, make sure to explain them in the comments.
  • When accepted, tag the RC branch with a v1.5.2.1 tag (or whatever version you finally ended up getting accepted), and push the tag to origin.
  • Merge RC into master.
  • On master, change the package version to 1.5.2.9000.
  • Tweet/blog!

Unable to compile on linux, "Mutex creation failed"

I can't compile later on my linux (Arch Linux), which breaks some dependencies for me. I get this error (both from github and CRAN):

``
** testing if installed package can be loaded
sh: riga 1: 5012 Annullato (core dump creato) '/usr/lib64/R/bin/R' --no-save --slave 2>&1 < '/tmp/Rtmp8kWDUc/file136713a0f686'
terminate called after throwing an instance of 'std::runtime_error'
what(): Mutex creation failed
ERROR: loading failed

  • removing ‘/usr/lib/R/library/later’
    ``
    This is my sessioninfo:

`R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS: /usr/lib/libblas.so.3.8.0
LAPACK: /usr/lib/liblapack.so.3.8.0

locale:
[1] LC_CTYPE=it_IT.UTF-8 LC_NUMERIC=C
[3] LC_TIME=it_IT.UTF-8 LC_COLLATE=it_IT.UTF-8
[5] LC_MONETARY=it_IT.UTF-8 LC_MESSAGES=it_IT.UTF-8
[7] LC_PAPER=it_IT.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] compiler_3.5.1 R6_2.2.2 htmltools_0.3.6 tools_3.5.1
[5] Rcpp_0.12.18 remotes_1.1.1 digest_0.6.15 fortunes_1.5-4
`

CRAN errors on Mac OS

I just did install.packages("later") and found that v0.6 binaries are not available, even though the last update wasn't in the past few days. later has ERRORs for the Mac builds for r-release and r-oldrel. Looks to be related to clock_gettime(), so presumably resolved by #21.

Rstudio server and the R event loop

Hi @jcheng5,

Awesome work on this! Look forward to start using it. I'm putting this issue here since this might be the smallest replicable example of this behavior, but it affects httpuv daemonization as well.

It seems that Rstudio server is messing with the R posix event loop (addInputHandler and friends). So the simple later::later(~print("Hello")) example doesn't work, as it doesn't evaluate the expression at all (the input handler is not called at all). After using later::run_now(), the expression is evaluated.

I've recreated it both running rstudio server through the rocker-org/rstudio docker container and
the Bioconductor AMI.

The example works as expected with R in the command line (after ssh into the container/instance).

Any ideas on how Rstudio server may be interfering with the R event loop?

PS. These docker/ami setups are used a lot for workshops and tutorials so it would be great make this work.

PS2. We have seen this (well, not using later, but for daemonized httpuv) work before on these rstudio server setups, as recently as last week, so this is a bit of a mystery.

Hang on install when used with ASAN builds of R

The hang is in pthread_create, which is called from a statically initialized copy of the Timer class. I'm not sure but maybe this is related:
https://reviews.llvm.org/D26028

I repro'd by configuring R-devel with:

./configure CC="gcc -std=gnu99 -fsanitize=address" \
  CFLAGS="-fno-omit-frame-pointer -g -O2 -Wall -pedantic -mtune=native"

which I copied from Writing R Extensions.

I have a feeling that delaying the creation of the timer bg thread until first use would fix it.

Installation failed on Raspberry PI 3 - Debian Stretch - R 3.5.1

I'm trying to install the package httpuv that depends on your package but the installation of later failed. I have a new installation of stretch where I just ran apt-get update && upgrade and installed R 3.5.1.

Following this, I tried to install your package through install.packages("later") that fail and through : sudo R CMD INSTALL later that failed too.

Here is the full log :

full log
pi@raspberrypi:~ $ R CMD config --all
CC = gcc -std=gnu99
CFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CPICFLAGS = -fpic
CPP = gcc -std=gnu99 -E
CPPFLAGS =
CXX = g++
CXXCPP = g++ -E
CXXFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXXPICFLAGS = -fpic
CXX11 = g++
CXX11STD = -std=gnu++11
CXX11FLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXX11PICFLAGS = -fpic
CXX14 = g++
CXX14STD = -std=gnu++14
CXX14FLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXX14PICFLAGS = -fpic
CXX98 = g++
CXX98STD = -std=gnu++98
CXX98FLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXX98PICFLAGS = -fpic
CXX17 =
CXX17STD =
CXX17FLAGS =
CXX17PICFLAGS =
CXX1X = g++
CXX1XSTD = -std=gnu++11
CXX1XFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
CXX1XPICFLAGS = -fpic
DYLIB_EXT = .so
DYLIB_LD = gcc -std=gnu99
DYLIB_LDFLAGS = -shared -fopenmp
F77 = gfortran
FFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong
FPICFLAGS = -fpic
FLIBS = -lgfortran -lm
SAFE_FFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong
FC = gfortran
FCFLAGS = -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong
FCPICFLAGS = -fpic
OBJC =
OBJCFLAGS =
JAVA = /usr/lib/jvm/default-java/jre/bin/java
JAVAC = /usr/lib/jvm/default-java/bin/javac
JAVAH = /usr/lib/jvm/default-java/bin/javah
JAR = /usr/lib/jvm/default-java/bin/jar
JAVA_HOME = /usr/lib/jvm/default-java
JAVA_LIBS = -L/usr/lib/jvm/default-java/jre/lib/arm/client -ljvm
JAVA_CPPFLAGS = -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux
LDFLAGS = -Wl,-z,relro
SHLIB_CFLAGS =
SHLIB_CXXLD = g++
SHLIB_CXXLDFLAGS = -shared
SHLIB_CXX98LD = g++ -std=gnu++98
SHLIB_CXX98LDFLAGS = -shared
SHLIB_CXX11LD = g++ -std=gnu++11
SHLIB_CXX11LDFLAGS = -shared
SHLIB_CXX14LD = g++ -std=gnu++14
SHLIB_CXX14LDFLAGS = -shared
SHLIB_CXX17LD =
SHLIB_CXX17LDFLAGS = -shared
SHLIB_EXT = .so
SHLIB_FFLAGS =
SHLIB_LD = gcc -std=gnu99
SHLIB_LDFLAGS = -shared
SHLIB_FCLD = gfortran
SHLIB_FCLDFLAGS = -shared
SHLIB_CXX1XLD = g++ -std=gnu++11
SHLIB_CXX1XLDFLAGS = -shared
TCLTK_CPPFLAGS = -I/usr/include/tcl8.6 -I/usr/include/tcl8.6
TCLTK_LIBS = -L/usr/lib/arm-linux-gnueabihf -ltcl8.6 -L/usr/lib/arm-linux-gnueabihf -ltk8.6 -lX11 -lXss -lXext
BLAS_LIBS = -lblas
LAPACK_LIBS = -llapack
MAKE = make
LIBnn = lib
LOCAL_SOFT =
COMPILED_BY =
pi@raspberrypi:~ $ git clone https://github.com/rstudio/httpuv.git
Cloning into 'httpuv'...
remote: Enumerating objects: 447, done.
remote: Counting objects: 100% (447/447), done.
remote: Compressing objects: 100% (308/308), done.
remote: Total 3791 (delta 191), reused 222 (delta 136), pack-reused 3344
Receiving objects: 100% (3791/3791), 3.97 MiB | 2.68 MiB/s, done.
Resolving deltas: 100% (2147/2147), done.
pi@raspberrypi:~ $ sudo R CMD INSTALL httpuv
* installing to library ‘/usr/local/lib/R/site-library’
ERROR: dependencies ‘promises’, ‘later’ are not available for package ‘httpuv’
* removing ‘/usr/local/lib/R/site-library/httpuv’
pi@raspberrypi:~ $ git clone https://github.com/r-lib/later.git
Cloning into 'later'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 790 (delta 0), reused 0 (delta 0), pack-reused 789
Receiving objects: 100% (790/790), 156.68 KiB | 0 bytes/s, done.
Resolving deltas: 100% (497/497), done.
pi@raspberrypi:~ $ sudo R CMD INSTALL later
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘later’ ...
Running configure script
Using CC=gcc -std=gnu99
Using CFLAGS=-g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g
Using CPPFLAGS=
C11-style threads.h support not detected. Using tinycthread library.
** libs
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c callback_registry.cpp -o callback_registry.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.cpp:3:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind/bind.hpp:26,
                 from /usr/local/lib/R/site-library/BH/include/boost/bind.hpp:22,
                 from callback_registry.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c later.cpp -o later.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/function/detail/prologue.hpp:18,
                 from /usr/local/lib/R/site-library/BH/include/boost/function.hpp:30,
                 from callback_registry.h:7,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later.cpp:2:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c later_native.cpp -o later_native.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/function/detail/prologue.hpp:18,
                 from /usr/local/lib/R/site-library/BH/include/boost/function.hpp:30,
                 from callback_registry.h:7,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_native.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from callback_registry.h:4,
                 from later_native.cpp:1:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c later_posix.cpp -o later_posix.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/function/detail/prologue.hpp:18,
                 from /usr/local/lib/R/site-library/BH/include/boost/function.hpp:30,
                 from callback_registry.h:7,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from callback_registry.h:8,
                 from later_posix.cpp:10:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/bits/locale_conv.h:41:0,
                 from /usr/include/c++/6/locale:43,
                 from /usr/include/c++/6/iomanip:43,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:52,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from later_posix.cpp:3:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
later_posix.cpp: In function ‘void deInitialize()’:
later_posix.cpp:187:33: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
     write(dummy_pipe_in, "a", 1);
                                 ^
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c later_win32.cpp -o later_win32.o
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c timer_posix.cpp -o timer_posix.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/bind/mem_fn.hpp:25:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/mem_fn.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/function/detail/prologue.hpp:18,
                 from /usr/local/lib/R/site-library/BH/include/boost/function.hpp:30,
                 from timer_posix.h:7,
                 from timer_posix.cpp:6:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp: At global scope:
/usr/local/lib/R/site-library/BH/include/boost/get_pointer.hpp:48:40: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template<class T> T * get_pointer(std::auto_ptr<T> const& p)
                                        ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timer_posix.h:6,
                 from timer_posix.cpp:6:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c timestamp_unix.cpp -o timestamp_unix.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:28:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/shared_count.hpp:355:33: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:256:65: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
 template< class T, class R > struct sp_enable_if_auto_ptr< std::auto_ptr< T >, R >
                                                                 ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:471:31: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     explicit shared_ptr( std::auto_ptr<Y> & r ): px(r.get()), pn()
                               ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:484:22: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr( std::auto_ptr<Y> && r ): px(r.get()), pn()
                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:567:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> & r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:576:34: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
     shared_ptr & operator=( std::auto_ptr<Y> && r )
                                  ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
In file included from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17:0,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp: In member function ‘boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(std::auto_ptr<_Up>&&)’:
/usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:578:38: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         this_type( static_cast< std::auto_ptr<Y> && >( r ) ).swap( *this );
                                      ^~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from /usr/local/lib/R/site-library/BH/include/boost/config/no_tr1/memory.hpp:21,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from timestamp.h:4,
                 from timestamp_unix.cpp:4:
/usr/include/c++/6/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^~~~~~~~
g++  -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c timestamp_win32.cpp -o timestamp_win32.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/BH/include"    -fpic  -g -O2 -fdebug-prefix-map=/root/git/r-backports/stretch/r-base-3.5.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c tinycthread/tinycthread.c -o tinycthread/tinycthread.o
g++ -shared -L/usr/lib/R/lib -Wl,-z,relro -o later.so RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o -pthread ./tinycthread/tinycthread.o -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/later/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for ‘later’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/local/lib/R/site-library/later/libs/later.so':
  /usr/local/lib/R/site-library/later/libs/later.so: undefined symbol: _ZN5boost7atomics6detail8lockpool11scoped_lockD1Ev
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/site-library/later’

</detail>

Any idea why i'm failing to install it ?

Alpine: Package fails to load with 'Mutex creation failed' error

Hello,

I've tried building later in Alpine 3.7 and the testing stage fails with:

** testing if installed package can be loaded
terminate called after throwing an instance of 'std::runtime_error'
  what():  Mutex creation failed
Aborted (core dumped)
ERROR: loading failed

This can be reproduced with:

$ sudo docker pull alpine:3.7
$ sudo docker run --rm -it alpine:3.7
# apk add --no-cache R R-dev build-base
# R
> install.packages('later')

I'm installing this as it's a dependency for a shiny application which in turns depends on pool which I'm trying to run in Docker. Alpine uses https://www.musl-libc.org instead of the glibc commonly found in other Linux distributions.

I've also tried master with remotes::install_github("r-lib/later") and it has the same issue.

R process crashes if interrupt happens during later's call to sys.nframe

I believe this is the root cause of rstudio/shiny#2081.

When an interrupt occurs during later's internal call to sys.nframe(), it throws an exception that is not caught. The call is here:

later/src/later.cpp

Lines 39 to 40 in 207d4e0

PROTECT(e = Rf_lang1(Rf_install("sys.nframe")));
PROTECT(result = R_tryEval(e, R_BaseEnv, &errorOccurred));

It is called (indirectly) from here

if (!at_top_level()) {

and from here

if (!at_top_level()) {

I had a hard time reproducing this error by calling later() and pressing Esc or Ctrl-C. However, this code crashes with a similar stack trace -- it replaces sys.nframe with a version which calls stop() when it detects its being run at the top level.

# Make sure we throw only once -- in Windows it can happen multiple times if we're not careful
has_thrown <- FALSE
sys.nframe2 <- function() {
  if (!has_thrown && length(sys.calls()) == 1) {
    has_thrown <<- TRUE
    stop("sys.nframe called from later's callback execution code. Throwing error.")
  }
  .Internal(sys.nframe())
}
assignInNamespace("sys.nframe", sys.nframe2, "base")

later::later(function() cat("hello"))

This causes R to crash on both Windows and Mac.

If R is run from cmd.exe in Windows, it prints this:

Error in sys.nframe() :
  sys.nframe called from later's callback execution code. Throwing error.
terminate called after throwing an instance of 'Rcpp::exception'
  what():  Error occurred while calling sys.nframe()

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

If run in RGui, it puts up a dialog with the "terminate it in an unusual way" text. If run in RStudio, the IDE crashes.

On a Mac, it prints this:

Error in sys.nframe() : 
  sys.nframe called from later's callback mechanism. Throwing error.
libc++abi.dylib: terminating with uncaught exception of type Rcpp::exception: Error occurred while calling sys.nframe()
Abort trap: 6

To trigger the error under gdb, and catch it so that the state of the program can be inspected, first install later with debugging information:

install.packages("later", type="source", INSTALL_opts = "--debug")

Then run the following in cmd.exe:

c:\Rtools\mingw_64\bin\gdb c:\Progra~1\R\R-3.5.0\bin\x64\Rgui.exe
break Rcpp::exception::exception
y
run

In the RGui window, run the R code from above. This will cause an exception.

Here's a log of what I did in the cmd.exe window:

Breakpoint 1, Rcpp::exception::exception (this=0x1ab95480,
    message_=0x18e699f0 <CallEntries+304> "Error occurred while calling sys.nframe()", include_call=true)
    at C:/Users/winst/R/3.5/Rcpp/include/Rcpp/exceptions.h:36
36                  include_call_(include_call){
(gdb) bt
#0  Rcpp::exception::exception (this=0x1ab95480,
    message_=0x18e699f0 <CallEntries+304> "Error occurred while calling sys.nframe()", include_call=true)
    at C:/Users/winst/R/3.5/Rcpp/include/Rcpp/exceptions.h:36
#1  0x0000000018dd2df8 in at_top_level () at later.cpp:60
#2  0x0000000018dd352c in executeHandlers () at later_win32.cpp:36
#3  0x0000000018dd36cc in callbackWndProc (hWnd=0xf0684, message=275, wParam=1, lParam=0) at later_win32.cpp:73
#4  0x00007ffe7a8cb85d in USER32!CallWindowProcW () from C:\Windows\System32\user32.dll
#5  0x00007ffe7a8cb1ef in USER32!DispatchMessageW () from C:\Windows\System32\user32.dll
#6  0x000000006355751b in GA_doevent () from c:\Progra~1\R\R-3.5.0\bin\x64\Rgraphapp.dll
#7  0x000000006c720b95 in R_ProcessEvents () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#8  0x000000006c706b7d in freeConsoleData () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#9  0x000000006c72098f in R_setStartTime () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#10 0x000000006c82e732 in Rf_ReplIteration () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#11 0x000000006c82ea51 in Rf_ReplIteration () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#12 0x000000006c82eae2 in run_Rmainloop () from c:\Progra~1\R\R-3.5.0\bin\x64\R.dll
#13 0x00000000004016b7 in ?? ()
#14 0x000000000040155a in ?? ()
#15 0x00000000004013e8 in ?? ()
#16 0x00000000004014eb in ?? ()
#17 0x00007ffe7ae01fe4 in KERNEL32!BaseThreadInitThunk () from C:\Windows\System32\kernel32.dll
#18 0x00007ffe7c44efb1 in ntdll!RtlUserThreadStart () from C:\Windows\SYSTEM32\ntdll.dll
#19 0x0000000000000000 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) fr 1
#1  0x0000000018dd2df8 in at_top_level () at later.cpp:60
60      later.cpp: No such file or directory.
(gdb) p nframe
$1 = -1
(gdb) c
Continuing.
[Thread 11144.0x2d10 exited with code 0]
terminate called after throwing an instance of 'Rcpp::exception'
  what():  Error occurred while calling sys.nframe()

At this point, RGui displays the following dialog:

image

later breaks socket wait (and `future` package)

There's an incompatibility between later and this piece of code in R_SocketWait:

https://github.com/wch/r-source/blob/f2a17ffe009aeeee3f2ee769a6114051a2a6678a/src/modules/internet/Rsock.c#L268-L275

My understanding of this code is that this code is intended to detect "false positives" in the R_SelectEx that occurs a few lines above; R_SocketWait only cares about its socket being ready to read or write, but if R_SelectEx will also return because other, unrelated, input handlers are ready. If this condition is detected, R_SocketWait executes a single input handler and then begins the loop again, reasonably assuming that executing the handler will cause its file descriptor to go cold.

The input handler installed by later doesn't go cold in many cases, it stays hot until R code stops executing. This means that R_SocketWait will never return, and since it was R code that is indirectly calling R_SocketWait, later's file descriptor will never go cold. So we effectively have deadlock (although interrupting R does work fine).

This is a simple repro case:

library(future)
library(magrittr)
plan(multisession)
later::later(~cat("done\n"), 10)
future({Sys.sleep(2);10}) %>% value()

The expected behavior is that [1] 10 is printed at the console after 2 seconds, then the console prompt returns, then done is printed after 10 seconds.

GCC and Boost version requirements

Hello,

I was attempting to install later on RHEL 6.6, which has the following version of gcc:

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and version 1.41 of the Boost C++ libraries installed on it.

What are the minimum requirements for Boost and GCC?

Also, is it possible to use autoconf and make to build this package? That way we can specify an $INCLUDE_PATH for newer versions Boost libraries. Overriding the gcc version can easily be accomplished by adding it to the $PATH.

compilation failed for package ‘later’

  • installing source package ‘later’ ...
    ** package ‘later’ successfully unpacked and MD5 sums checked
    Running configure script
    Using CC=gcc -std=gnu99
    Using CFLAGS=-g -O2
    Using CPPFLAGS=-I/usr/local/include
    C11-style threads.h support not detected. Using tinycthread library.
    ** libs
    g++ -I/software/development/Build/R-3.4.0/lib64/R/include -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/software/development/Build/R-3.4.0/lib64/R/library/Rcpp/include" -I"/software/development/Build/R-3.4.0/lib64/R/library/BH/include" -I/usr/local/include -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    g++ -I/software/development/Build/R-3.4.0/lib64/R/include -DNDEBUG -pthread -DTHREADS_H_SUPPORT=-1 -I"/software/development/Build/R-3.4.0/lib64/R/library/Rcpp/include" -I"/software/development/Build/R-3.4.0/lib64/R/library/BH/include" -I/usr/local/include -fpic -g -O2 -c callback_registry.cpp -o callback_registry.o
    In file included from callback_registry.h:9:0,
    from callback_registry.cpp:6:
    timestamp.h:18:3: error: ‘boost’ does not name a type
    boost::shared_ptr p_impl;
    ^
    timestamp.h: In member function ‘bool Timestamp::future() const’:
    timestamp.h:26:12: error: ‘p_impl’ was not declared in this scope
    return p_impl->future();
    ^
    timestamp.h: In member function ‘bool Timestamp::operator<(const Timestamp&) const’:
    timestamp.h:31:12: error: ‘p_impl’ was not declared in this scope
    return p_impl->less(other.p_impl.get());
    ^
    timestamp.h:31:31: error: ‘const class Timestamp’ has no member named ‘p_impl’
    return p_impl->less(other.p_impl.get());
    ^
    timestamp.h: In member function ‘bool Timestamp::operator>(const Timestamp&) const’:
    timestamp.h:34:12: error: ‘p_impl’ was not declared in this scope
    return p_impl->greater(other.p_impl.get());
    ^
    timestamp.h:34:34: error: ‘const class Timestamp’ has no member named ‘p_impl’
    return p_impl->greater(other.p_impl.get());
    ^
    timestamp.h: In member function ‘double Timestamp::diff_secs(const Timestamp&) const’:
    timestamp.h:39:12: error: ‘p_impl’ was not declared in this scope
    return p_impl->diff_secs(other.p_impl.get());
    ^
    timestamp.h:39:36: error: ‘const class Timestamp’ has no member named ‘p_impl’
    return p_impl->diff_secs(other.p_impl.get());
    ^
    In file included from callback_registry.h:11:0,
    from callback_registry.cpp:6:
    threadutils.h: At global scope:
    threadutils.h:15:15: error: ‘boost’ has not been declared
    class Mutex : boost::noncopyable {
    ^
    threadutils.h:15:22: error: expected ‘{’ before ‘noncopyable’
    class Mutex : boost::noncopyable {
    ^
    threadutils.h:15:34: error: invalid type in declaration before ‘{’ token
    class Mutex : boost::noncopyable {
    ^
    threadutils.h:15:34: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
    threadutils.h:16:3: error: expected primary-expression before ‘friend’
    friend class ConditionVariable;
    ^
    threadutils.h:16:3: error: expected ‘}’ before ‘friend’
    threadutils.h:16:3: error: expected ‘,’ or ‘;’ before ‘friend’
    threadutils.h:19:1: error: expected unqualified-id before ‘public’
    public:
    ^
    make: *** [callback_registry.o] Error 1
    ERROR: compilation failed for package ‘later’
  • removing ‘/software/development/Build/R-3.4.0/lib64/R/library/later’

The downloaded source packages are in
‘/tmp/RtmpGW5RgB/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages(c("later")) :
installation of package ‘later’ had non-zero exit status

I tried installing from CRAN, but that didnt work. Any suggestions?

unable to compile on windows

Hi Joe,

Any ideas as to the problem with the following compilation error

> devtools::install_github("r-lib/later")
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo r-lib/later@master
from URL https://api.github.com/repos/r-lib/later/zipball/master
Installing later
"C:/PROGRA~1/R/R-34~1.0/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  "C:/Users/devin/AppData/Local/Temp/RtmpoXC0Bm/devtools636c246f1b26/r-lib-later-8d6b106" --library="C:/Users/devin/Documents/R/win-library/3.4" --install-tests 

* installing *source* package 'later' ...
** libs

*** arch - i386
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c callback_registry.cpp -o callback_registry.o
c:/Rtools/mingw_32/bin/gcc  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O3 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c later.cpp -o later.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c later_native.cpp -o later_native.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c later_posix.cpp -o later_posix.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c later_win32.cpp -o later_win32.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c timer_posix.cpp -o timer_posix.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c timestamp_unix.cpp -o timestamp_unix.o
c:/Rtools/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-34~1.0/include" -DNDEBUG -pthread -I"C:/Users/devin/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/devin/Documents/R/win-library/3.4/BH/include"   -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c timestamp_win32.cpp -o timestamp_win32.o
timestamp_win32.cpp: In constructor 'Timestamp::Timestamp()':
timestamp_win32.cpp:40:56: error: invalid new-expression of abstract class type 'TimestampImplWin32'
 Timestamp::Timestamp() : p_impl(new TimestampImplWin32()) {}
                                                        ^
timestamp_win32.cpp:7:7: note:   because the following virtual functions are pure within 'TimestampImplWin32':
 class TimestampImplWin32 : public TimestampImpl {
       ^
In file included from timestamp_win32.cpp:3:0:
timestamp.h:13:18: note: 	virtual double TimestampImpl::diff_secs(const TimestampImpl*) const
   virtual double diff_secs(const TimestampImpl* other) const = 0;
                  ^
timestamp_win32.cpp: In constructor 'Timestamp::Timestamp(double)':
timestamp_win32.cpp:41:71: error: invalid new-expression of abstract class type 'TimestampImplWin32'
 Timestamp::Timestamp(double secs) : p_impl(new TimestampImplWin32(secs)) {}
                                                                       ^
make: *** [timestamp_win32.o] Error 1
Warning: running command 'make -f "Makevars" -f "C:/PROGRA~1/R/R-34~1.0/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-34~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="later.dll" OBJECTS="RcppExports.o callback_registry.o init.o later.o later_native.o later_posix.o later_win32.o timer_posix.o timestamp_unix.o timestamp_win32.o"' had status 2
ERROR: compilation failed for package 'later'

cherry-picked package info if you need it:

> devtools::session_info()
Session info -----------------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.0 (2017-04-21)
 system   x86_64, mingw32             
 ui       RStudio (1.1.327)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2017-08-18             

 Rcpp        0.12.12 2017-07-15 CRAN (R 3.4.1)
 BH        1.62.0-1 2016-11-19 CRAN (R 3.4.0)
     

Race conditions

When running a (multithreaded) httpuv test app with valgrind + helgrind, it says there are possible races in the following:

  • Simultaneous calls to set_fd
  • Timestamp::diff_secs() and TimestampImplPosix::~TimestampImplPosix()

There are also some minor locking/unlocking issues when quitting R. Their effects are probably unimportant though.

Full output here:
https://gist.github.com/wch/9818a0321782c4e3cfcf321ee9a87cdb

Request: more informative message when error occurs

If an error occurs when running a callback, it prints out an error message, but it can be difficult to track down the source. For example:

> later::later(identity)
later: exception occurred while executing callback: 
Evaluation error: argument "x" is missing, with no default.
> traceback()
No traceback available 

Since there's no stack trace, it can be hard to find exactly where the error occurred.

There's a similar problem if the callback is invoked via run_now(). In that case, you get a stack trace, but it only tells you that the error was triggered from execCallbacks; it doesn't show you the function where the error actually occurred.

> later::later(identity, 1)
> later::run_now(1)
Error in execCallbacks(timeoutSecs) : 
  Evaluation error: argument "x" is missing, with no default.
> traceback()
4: stop(list(message = "Evaluation error: argument \"x\" is missing, with no default.", 
       call = execCallbacks(timeoutSecs), cppstack = NULL))
3: .Call("_later_execCallbacks", PACKAGE = "later", timeoutSecs)
2: execCallbacks(timeoutSecs)
1: later::run_now(1)

Using options(error=recover) in this case only lets you go as far as execCallbacks; it won't let you get into the actual callback (in this case, identity).

100% CPU in Console

A user noticed over at rstudio/websocket#34 that websocket seems to use 100% when run from the R console.

This problem doesn't seem to manifest in RStudio. The following code run at the console will demonstrate the problem:

library(later)

testLater <- function() {
  later::later(testLater, 0.01)
}

testLater()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

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     datasets  methods   base

other attached packages:
[1] later_0.7.5

loaded via a namespace (and not attached):
[1] compiler_3.5.1 Rcpp_0.12.19   rlang_0.3.0.1

GC events can cause Error: unimplemented type 'integer' in 'coerceToInteger'

For example:

R
library(later)

f <- function() {
  for (j in 1:3) {
    later(function() {
      cat(".\n")
    })
  }
  gctorture(T)
}

f()

When I run this I get:

> f()
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
> Error: unimplemented type 'integer' in 'coerceToInteger'
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 
> Error: unimplemented type 'integer' in 'coerceToInteger'
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 
> Error: unimplemented type 'integer' in 'coerceToInteger'
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 
> Error: unimplemented type 'integer' in 'coerceToInteger'
In addition: Warning message:
An unusual circumstance has arisen in the nesting of readline input. Please report using bug.report() 
> .
.
.

Exception in a later function causes later to stop working

Example:

library(later)
later(function() {
  cat("1\n", file=stderr())
  stop()
  cat("2\n", file=stderr())
})


later(function() {
  cat("hello\n", file=stderr())
})

This produces the following output when run in the terminal:

> library(later)
> later(function() {
+   cat("1\n", file=stderr())
+   stop()
+   cat("2\n", file=stderr())
+ })
> 1
Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
  Evaluation error: .
> later(function() {
+   cat("hello\n", file=stderr())
+ })
> 

Something similar happens if, instead of stop(), you have browser(), and then Q out of the browser -- future calls to later() don't do anything.

Limit to delay seconds

Using a quite large number of delay seconds (30-70.000) the delay does work, and delay work like it was 0).

Exceptions are uncaught when run from inputhandler

Normally, if you call an Rcpp function which calls an R function, and the R code throws an exception (like an interrupt or error), that exception is caught by the try-catch in the BEGIN_RCPP and END_RCPP macros.

However, if later() is run via the input handler route (as opposed to run_now()), then the exceptions are not caught, because it's not wrapped in BEGIN_RCPP and END_RCPP.

Here's an example of a callback being invoked by run_now:

library(later)
{
    later(function() stop("an error here"))
    run_now()
}
#> Error in execCallbacks(timeoutSecs) : Evaluation error: an error here.

And here it is when it's invoked by the R input handler route:

later::later(function() stop("an error here"))
#> Error in tryCatch(evalq(sys.calls(), <environment>), error = function (x)  : 
#>  Evaluation error: an error here.

Additionally, in the latter case, it messes up the terminal when you quit R. These uncaught exceptions are probably the root cause of #25 and #29.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.