You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 carefulhas_thrown<-FALSEsys.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:
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:
The text was updated successfully, but these errors were encountered:
A way to trigger the error with a user interrupt (instead of stop()) is to modify sys.nframe() to wait for a few seconds, and then press Esc/Ctrl-C while it's waiting.
sys.nframe2<-function() {
if (length(sys.calls()) ==1) {
cat("pausing for 5 seconds. Press Esc or Ctrl-C now...\n", file= stderr())
Sys.sleep(5)
cat("done.\n", file= stderr())
}
.Internal(sys.nframe())
}
assignInNamespace("sys.nframe", sys.nframe2, "base")
later::later(function() cat("hello"))
The behavior is essentially the same as when stop() was called previously.
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
It is called (indirectly) from here
later/src/later_win32.cpp
Line 36 in 207d4e0
and from here
later/src/later_posix.cpp
Line 84 in 207d4e0
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 replacessys.nframe
with a version which callsstop()
when it detects its being run at the top level.This causes R to crash on both Windows and Mac.
If R is run from cmd.exe in Windows, it prints this:
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:
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:
Then run the following in cmd.exe:
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:
At this point, RGui displays the following dialog:
The text was updated successfully, but these errors were encountered: