Skip to content

gctorture and proc.time (PR#10600)

5 messages · Charles Geyer, Peter Dalgaard, Stephen Milborrow +2 more

#
In R version 2.6.1 (2007-11-26)
and R version 2.6.1 Patched (2008-01-19 r44061)
on openSUSE 10.2 (X86-64)
Error: protect(): protection stack overflow

The problem with this is that then

R CMD check --use-gct foo

ALWAYS FAILS with
Error in proc.time() - get("ptime", pos = "CheckExEnv") :
  non-numeric argument to binary operator

This does not happen in R version 2.4.1 (2006-12-18)

I was going to have my computing class try out --use-gct.
I guess not until this is fixed.
#
charlie at stat.umn.edu wrote:
I can reproduce this on SUSE 10.2 64 bit and Fedora 7 64 bit, but not on 
SUSE 10.3 32 bit and Fedora 8 32 bit. (The OS versions are likely not 
relevant, I bet it is a 64 bit issue somewhere).
#
I'm not sure if this is connected but in R2.6.1 do_proctime is missing some
PROTECTs. The current code is

 SEXP ans = allocVector(REALSXP, 5), nm = allocVector(STRSXP, 5);

and should be

    SEXP ans, nm;
    PROTECT(ans = allocVector(REALSXP, 5));
    PROTECT(nm = allocVector(STRSXP, 5));

A good way of finding these missing PROTECTs is to write say 0xEE to memory
as it is freed (i.e. one must modify the source of memory.c). Then with gc
torture enabled it more obvious if  someone uses a just freed SEXP.  There
is a similar issue in a few other places which I haven't tracked down yet
which I will submit to r-bugs in due course.  These were found using the
0xEE trick and running make check-all.

Steve
www.milbo.users.sonic.net

----- Original Message ----- 
From: "Peter Dalgaard" <p.dalgaard at biostat.ku.dk>
To: <charlie at stat.umn.edu>
Cc: <R-bugs at biostat.ku.dk>; <r-devel at stat.math.ethz.ch>
Sent: Tuesday, January 22, 2008 9:56 AM
Subject: Re: [Rd] gctorture and proc.time (PR#10600)
charlie at stat.umn.edu wrote:
I can reproduce this on SUSE 10.2 64 bit and Fedora 7 64 bit, but not on
SUSE 10.3 32 bit and Fedora 8 32 bit. (The OS versions are likely not
relevant, I bet it is a 64 bit issue somewhere).
#
Peter Dalgaard wrote:
I can be a bit more precise - I have both 32-bit R and 64-bit R built 
and installed on fedora 8 64-bit, just one and same box.

32-bit R finishes quite quickly with:

 > proc.time()
    user  system elapsed
   0.772   0.032  10.147

64-bit R takes up 49s CPU time (from ps). This is long compared to 
either 10s (elapse) or 1s (user+sys). And it ends with:
Error: protect(): protection stack overflow

So yes, it looks like a 64-bit R specific bug.
#
Such things are normally easy to find with valgrind and an instrumented 
build of R (see 'Writing R Extensions'), and so was this.  Interestingly I 
got a different error immediately:
Error: REAL() can only be applied to a 'numeric', not a 'character'

and setting a breakpoint on that message traced it back.

It was a missing PROTECT, and has now been fixed.
On Wed, 23 Jan 2008, Hin-Tak Leung wrote: