On 04/19/2013 01:16 AM, Prof Brian Ripley wrote:
On 17/04/2013 21:25, Michael Lawrence wrote:
It's tough to reliably reproduce, but I often get stack imbalance warnings
when calling max.col() on non-real/double matrix. The code is conditionally
PROTECTing but not incrementing its nprot counter for the eventual
UNPROTECT. Pretty sure this would fix (but I haven't tested it):

I can't reproduce it either, but that seems the right fix so incorporated now,
thanks.

Why isn't this reproducible? I thought the protection stack would be 
deterministic.

> max.col(matrix())
Warning: stack imbalance in 'max.col', 10 then 11
Warning: stack imbalance in '.Internal', 9 then 10
Warning: stack imbalance in '{', 6 then 7
[1] NA

> sessionInfo()
R Under development (unstable) (2013-04-18 r62615)
Platform: x86_64-unknown-linux-gnu (64-bit)

from config.log

$ /home/mtmorgan/src/R-devel/configure --enable-memory-profiling --disable-byte-compiled-packages --enable-R-shlib CC=clang CFLAGS=-g -O0 CXX=clang++ CXXFLAGS=-g -O0 --no-create --no-recursion

with

$ clang --version
Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: x86_64-pc-linux-gnu
Thread model: posix




Index: array.c
===================================================================
--- array.c    (revision 61606)
+++ array.c    (working copy)
@@ -1614,7 +1614,10 @@
      SEXP m = CAR(args);
      int method = asInteger(CADR(args));
      int nr = nrows(m), nc = ncols(m), nprot = 1;
-    if (TYPEOF(m) != REALSXP) PROTECT(m = coerceVector(m, REALSXP));
+    if (TYPEOF(m) != REALSXP) {
+      PROTECT(m = coerceVector(m, REALSXP));
+      nprot++;
+    }
      SEXP ans = allocVector(INTSXP, nr);
      PROTECT(ans);
      R_max_col(REAL(m), &nr, &nc, INTEGER(ans), &method);

Thanks,
Michael

    [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel





--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to