[Rd] Missing objects using dump.frames for post-mortem debugging of crashed batch jobs. Bug or gap in documentation?

Martin Maechler maechler at stat.math.ethz.ch
Mon Nov 14 11:34:30 CET 2016


>>>>> nospam at altfeld-im de <nospam at altfeld-im.de>
>>>>>     on Sun, 13 Nov 2016 13:11:38 +0100 writes:

    > Dear R friends, to allow post-mortem debugging In my
    > Rscript based batch jobs I use

    >    tryCatch( <R expression>, error = function(e) {
    > dump.frames(to.file = TRUE) })

    > to write the called frames into a dump file.

    > This is similar to the method recommended in the "Writing
    > R extensions" manual in section 4.2 Debugging R code (page
    > 96):

    > https://cran.r-project.org/doc/manuals/R-exts.pdf

    >> options(error = quote({dump.frames(to.file=TRUE); q()}))



    > When I load the dump later in a new R session to examine
    > the error I use

    >     load(file = "last.dump.rda") debugger(last.dump)

    > My problem is that the global objects in the workspace are
    > NOT contained in the dump since "dump.frames" does not
    > save the workspace.

    > This makes debugging difficult.



    > For more details see the stackoverflow question + answer
    > in:
    > https://stackoverflow.com/questions/40421552/r-how-make-dump-frames-include-all-variables-for-later-post-mortem-debugging/40431711#40431711



    > I think the reason of the problem is:
    > ------------------------------------

    > If you use dump.files(to.file = FALSE) in an interactive
    > session debugging works as expected because it creates a
    > global variable called "last.dump" and the workspace is
    > still loaded.

    > In the batch job scenario however the workspace is NOT
    > saved in the dump and therefore lost if you debug the dump
    > in a new session.


    > Options to solve the issue:
    > --------------------------

    > 1. Improve the documentation of the R help for
    > "dump.frames" and the R_exts manual to propose another
    > code snippet for batch job scenarios:

    >       dump.frames() save.image(file = "last.dump.rda")

    > 2. Change the semantics of "dump.frames(to.file = TRUE)"
    > to include the workspace in the dump.  This would change
    > the semantics implied by the function name but makes the
    > semantics consistent for both "to.file" param values.

There is a third option, already in place for three months now:
Andreas Kersting did propose it (nicely, as a wish),
	https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17116
and I had added it to the development version of R back then :

------------------------------------------------------------------------
r71102 | maechler | 2016-08-16 17:36:10 +0200 (Tue, 16 Aug 2016) | 1 line

dump.frames(*, include.GlobalEnv)
------------------------------------------------------------------------

So, if you (or others) want to use this before next spring,
you should install a version of R-devel
and you use that, with

  tryCatch( <R expression>,
           error = function(e)
	           dump.frames(to.file = TRUE, include.GlobalEnv = TRUE))

Using R-devel is nice and helpful for the R community, as you
will help finding bugs/problems in the new features (and
possibly changed features) we've introduced there. 


Best regards,
Martin



More information about the R-devel mailing list