Skip to content

tests/ok-errors.R ## bad infinite recursion

7 messages · Brian Ripley, Thibaut Jombart, George Georgalis

#
I've come across a handful of tests that
fail at our site.  I consider this one the
worst because the process does not return.

The patch below simply bypasss the test,
but the errors in the out file are included
as well. I suspect this is due to more or
tighter ulimits on this system.

But I'm not sure if this is result of
different expectations (kernel/userland) of
what should be done in the curcumstance.

// George


NetBSD chime 4.0_STABLE NetBSD 4.0_STABLE (CHIME) #6: Tue Apr 29 16:49:55 EDT 2008  root at chime:/usr/obj/sys/arch/amd64/compile/CHIME amd64

time(cpu-seconds)    unlimited
file(blocks)         unlimited
coredump(blocks)     1
data(kbytes)         262144
stack(kbytes)        2048
lockedmem(kbytes)    670964
memory(kbytes)       2012892
nofiles(descriptors) 64
processes            160
sbsize(bytes)        unlimited



--- ok-errors.R.orig    2007-09-25 18:05:05.000000000 -0400
+++ ok-errors.R 2008-05-21 16:09:12.000000000 -0400
@@ -16,7 +16,40 @@

 getenv("USER") # should produce correct error message.

-## bad infinite recursion / on.exit / ... interactions
-bar <- function() 1+1
-foo <- function() { on.exit(bar()); foo() }
-foo() # now simple "infinite recursion"
+### bad infinite recursion / on.exit / ... interactions
+#bar <- function() 1+1
+#foo <- function() { on.exit(bar()); foo() }
+#foo() # now simple "infinite recursion"
+#
+#
+#> ## bad infinite recursion / on.exit / ... interactions
+#> bar <- function() 1+1
+#> foo <- function() { on.exit(bar()); foo() }
+#> foo() # now simple "infinite recursion"
+#Error: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error: segfault from C stack overflow
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#Error during wrapup: C stack usage is too close to the limit
+#Error: C stack usage is too close to the limit
+#
+# and machine remains at load of 1, R process does not exit or log for several minutes.
#
Why not raise your limits to more reasonable levels?  These failures are 
warning you that your limits (stack, it looks) are too low.

We do know from experience on Windows that a 2Mb stack limit is too low, 
and recommend 10Mb (and that is on a 32-bit system).

Also, the descriptors limit should be at least 128 (and no system we 
looked at recently had less than 256).
On Thu, 22 May 2008, George Georgalis wrote:

            

  
    
1 day later
#
On Thu 22 May 2008 at 07:09:51 PM +0100, Prof Brian Ripley wrote:
These are the default netbsd levels (soft limit). As a user I
can raise the stack to 3072 and the test exits with the expected
result.

However, isn't the purpose of the test to identify if something is
wrong? The problem is: there was _no_failure_ when the ulimit was
reached!  When the stack limit is reached the process adds 1 to
the load and does not log or return.

An arbitrary amount of stack may be used before a 'recursive
infinite loop is invoked' so just raising the ulimit doesn't
fix anything other than making the test pass, it just hides the
problem.

These ulimits have been in place for some time on our production
systems, with no problem. Only problem we have experienced is the
test script.

Incidentally ktrace did not indicate what was going on after the
process reached point of no return.
We have never run out of file descriptors, and given our modeling
tasks, it is unlikely this will ever happen.

At this point I'm looking for a consensus as to whether the shell,
kernel, or R should kill the process when the stack (or another)
ulimit is reached.

I'm thinking it is the kernel/shell that should kill a process
that touches a ulimit; but I'm not 100% on this.

// George

  
    
#
The test has warned you about a problem with your OS, and I have already 
told you how to solve it.  If you don't want to do that, the test will 
continue to remind you.
On Fri, 23 May 2008, George Georgalis wrote:

            
Your assertion is simply wrong -- the amount is not 'arbitrary'.
R (where possible) stops this being reached -- you seem unfamiliar with 
the R manuals.

  
    
#
Dear Martin,

thank you for your answer. My question is indeed the same as:

http://tolstoy.newcastle.edu.au/R/e2/devel/07/09/4469.html

Sorry for missing it.

 > The short answer seems to be that this is fixed in the devel
 > implementation of S4 (at least, my effort at reproducing this was
 > successful in 2.7 but not R version 2.8.0 Under development (unstable)
 > (2008-05-22 r45762)).

I just tried with the current devel version:
R version 2.8.0 Under development (unstable) (2008-05-23 r45768)
i686-pc-linux-gnu

and the problem still occured.
I also read the answers to you previously-cited post. I too believe it 
is still better not to load the package automatically than loading it 
with undesired side-effects. Maybe a word about this issue would be 
useful in the manpage of 'show'?

Best,

Thibaut.
######################################
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biom?trie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
T?l. : 04.72.43.29.35
Fax : 04.72.43.13.88
jombart at biomserv.univ-lyon1.fr
http://biomserv.univ-lyon1.fr/%7Ejombart/
http://adegenet.r-forge.r-project.org/
#
On Sat 24 May 2008 at 08:04:03 AM +0100, Prof Brian Ripley wrote:
Well we have been digging a little deeper, here is a ktrace
http://pastebin.ca/1028465

there is lots of checks/warnings that the stack limit is
getting close, but when R hits the limit it gets SIGSEGV
and should abort, longjmp or something (line 194):

 14824      1 R        PSIG  SIGSEGV caught handler=0x411a90 mask=(): code=SEGV_ACCERR, addr=0x7f7fffdff670, trap=6)

What it actually does is try to wrapup and such till it
hits line 330, at which point it sits, uses cycles, till
I ctrl-c it on line 331.

I think when it gets SIGSEGV it should exit, but it
would seem the "C stack usage is too close to the limit"
to stderr checks or some other use of resources to wrap
up are causing failure to exit. Warnings about stack
running out are cool but not if the check causes the
process to hang when the resource does run out.
I don't see how raising the stack ulimit would fix
the problem; what if we had 768K on the stack before
invoking an infinite loop? The process would not exit
or progress. Exactly the problem the test is trying to
identify.

// George

  
    
#
On Sat 24 May 2008 at 10:27:57 PM -0400, George Georgalis wrote:
I didn't see this part of your responce before...
are you saying, no matter what the context, the R process will
always use the exact (or near enough) amount of stack and will
always begin counting from 0 to the ulimit?
The failure to exit on SIGSEGV seems pretty clear; I am
not unfamiliar with the R manuals but I've not read them
all either. Is there something in particular I should be
looking at regarding this?

// George