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.


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



--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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

Reply via email to