'LIMIT' error from setTimeLimit bypassed by C-level code
0 reputation · 18 Nov 2023, 09:55 UTC
The goal is to release open file handles and temporary objects when an R expression exceeds a CPU time limit and stops.
setTimeLimit raises a catchable 'LIMIT' error at the R level, but compiled code invoked by the expression may not check the interrupt flag and can continue past the deadline. It is uncertain whether tryCatch around the whole call reliably executes on.exit cleanup when the timeout originates inside native code, or whether finalizers run before the session becomes unstable.
- Does
tryCatchguaranteeon.exitexecution after a'LIMIT'error raised from C-level code? - Should cleanup be registered with
reg.finalizerinstead ofon.exitto survive abrupt interruption? - Is there a portable way to force compiled code to honor R's time limit without changing its source?