From p.dalgaard@biostat.ku.dk  Tue Sep 22 17:20:51 1998
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 22 Sep 1998 18:20:51 +0200
Subject: "Segmentation Fault - core dumped" in R 0.62.3
In-Reply-To: Paul Gilbert's message of Tue, 22 Sep 1998 11:00:57 -0400
References: <98Sep22.112745edt.13470@mailgate.bank-banque-canada.ca>
Message-ID: <x23e9k5db0.fsf@blueberry.kubism.ku.dk>

Paul Gilbert <pgilbert@bank-banque-canada.ca> writes:

> I am occasional getting "Segmentation Fault - core dumped" in R 0.62.3 (I think
> more often then I did in 0.62.2). I have not been able to do this in any
> reliably reproducible way yet, but thought I would mention the problem in case
> some else can isolate it.

Hmm. Two rather nasty PROTECT bugs got fixed for 0.63 lately, but it
isn't all that easy to backport the fixes to 0.62.3 at this point
(several things have changed in 0.63)

Also, with our current garbage collector, the system appears to
playing Russian roulette if GC happens during parsing. Ross is
planning to install a better one for 0.64. This is more than tricky to
fix with the current memory scheme (it requires major surgery on
gram.y) so probably noone will try till then.

In general, this kind of crash is nearly always caused by a garbage
collection at *exactly* the wrong moment, so one generally needs exact
data to reproduce the crash, in order to pinpoint the trouble spot.

If you want to try the 0.63 fixes, a set of diffs follow. Note that
they are between two development versions, so they shouldn't be
expected to be directly applicable to 0.62.3.

[pd@blueberry R]$ cvs diff -c -r 1.23 -r 1.24 src/main/eval.c
Index: src/main/eval.c
===================================================================
RCS file: /users/rdev/R/CVS-ARCHIVE/R/src/main/eval.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -c -r1.23 -r1.24
*** /tmp/T0a005IJ       Wed Sep 23 04:03:07 1998
--- /tmp/T1a005IJ       Wed Sep 23 04:03:07 1998
***************
*** 727,733 ****
  
  SEXP do_set(SEXP call, SEXP op, SEXP args, SEXP rho)
  {
!     SEXP s;
      if (length(args) != 2)
        WrongArgCount(asym[PRIMVAL(op)]);
      if (isString(CAR(args)))
--- 727,733 ----
  
  SEXP do_set(SEXP call, SEXP op, SEXP args, SEXP rho)
  {
!     SEXP s, t;
      if (length(args) != 2)
        WrongArgCount(asym[PRIMVAL(op)]);
      if (isString(CAR(args)))
***************
*** 738,744 ****
        if (isSymbol(CAR(args))) {
            s = eval(CADR(args), rho);
            if (NAMED(s))
!               s = duplicate(s);
            PROTECT(s);
            R_Visible = 0;
            defineVar(CAR(args), s, rho);
--- 738,749 ----
        if (isSymbol(CAR(args))) {
            s = eval(CADR(args), rho);
            if (NAMED(s))
!           {
!               PROTECT(s);
!               t = duplicate(s);
!               UNPROTECT(1);
!               s = t;
!           }
            PROTECT(s);
            R_Visible = 0;
            defineVar(CAR(args), s, rho);
[pd@blueberry R]$ cvs diff -c -r 1.23 -r 1.24 src/main/par.c
Index: src/main/par.c
===================================================================
RCS file: /users/rdev/R/CVS-ARCHIVE/R/src/main/par.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -c -r1.23 -r1.24
*** /tmp/T0a005Ia       Wed Sep 23 04:04:05 1998
--- /tmp/T1a005Ia       Wed Sep 23 04:04:05 1998
***************
*** 1114,1121 ****
        INTEGER(value)[0] = dd->dp.ask;
      }
      else if (streql(what, "bg")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.bg));
      }
      else if (streql(what, "bty")) {
        char buf[2];
--- 1114,1122 ----
        INTEGER(value)[0] = dd->dp.ask;
      }
      else if (streql(what, "bg")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.bg));
+       UNPROTECT(1);
      }
      else if (streql(what, "bty")) {
        char buf[2];
***************
*** 1151,1174 ****
        REAL(value)[1] = dd->dp.cra[1]*dd->dp.ipr[1];
      }
      else if (streql(what, "col")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.col));
      }
      else if (streql(what, "col.main")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.colmain));
      }
      else if (streql(what, "col.lab")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.collab));
      }
      else if (streql(what, "col.sub")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.colsub));
      }
      else if (streql(what, "col.axis")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.colaxis));
      }
      else if (streql(what, "cra")) {
        value = allocVector(REALSXP, 2);
--- 1152,1180 ----
        REAL(value)[1] = dd->dp.cra[1]*dd->dp.ipr[1];
      }
      else if (streql(what, "col")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.col));
+       UNPROTECT(1);
      }
      else if (streql(what, "col.main")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.colmain));
+       UNPROTECT(1);
      }
      else if (streql(what, "col.lab")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.collab));
+       UNPROTECT(1);
      }
      else if (streql(what, "col.sub")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.colsub));
+       UNPROTECT(1);
      }
      else if (streql(what, "col.axis")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.colaxis));
+       UNPROTECT(1);
      }
      else if (streql(what, "cra")) {
        value = allocVector(REALSXP, 2);
***************
*** 1193,1200 ****
        INTEGER(value)[0] = dd->dp.err;
      }
      else if (streql(what, "fg")) {
!       value = allocVector(STRSXP, 1);
        STRING(value)[0] = mkChar(col2name(dd->dp.fg));
      }
      else if (streql(what, "fig")) {
        value = allocVector(REALSXP, 4);
--- 1199,1207 ----
        INTEGER(value)[0] = dd->dp.err;
      }
      else if (streql(what, "fg")) {
!       PROTECT(value = allocVector(STRSXP, 1));
        STRING(value)[0] = mkChar(col2name(dd->dp.fg));
+       UNPROTECT(1);
      }
      else if (streql(what, "fig")) {
        value = allocVector(REALSXP, 4);



-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


"Segmentation Fault - core dumped" in R 0.62.3
Peter Dalgaard BSA