Skip to content

Instantly share code, notes, and snippets.

@brodieG
Last active October 18, 2016 01:36
Show Gist options
  • Save brodieG/3732f747940fbb9c547e330b8610bf39 to your computer and use it in GitHub Desktop.
Save brodieG/3732f747940fbb9c547e330b8610bf39 to your computer and use it in GitHub Desktop.
Browser Bugs With on.exit
# Tested on OS X and Ubuntu R 3.3.1, appears fixed in R-devel
# WARNING: you may have to kill your session if you run the code here
fun <- function() {
on.exit(cat('exited\n'))
stop('hello')
}
{
browser()
# type `fun()` at Browser[1]> prompt to cause infinite loop
}
@brodieG
Copy link
Author

brodieG commented Oct 18, 2016

Somehow looks like the on.exit call causes R to lose track of context and results in the abort restart re-evaluating fun, but only when in browser() context as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment