[Rd] segfault

Paul Gilbert gilb@home.com
Thu, 22 Feb 2001 13:05:24 -0500


A few people suggested ddd might be preferred to xxgdb, where upon xxgdb
crashed on me. I have now managed to get ddd working on my linux box at
home, but am still having some difficulty at work. (It requires a newer
c++ ,  some *tif libraries, etc.)

---- Peter D.  writes:
>The actual bug is probably somewhat prior to this. If you do a "bt"
>(backtrace) and go "up" a couple of times, you might find a spot where
>someone forgot to PROTECT() a newly created R object.

Well ddd  still does not install the innocent with the knowlege of C
programmers so I am guessing a bit about exactly what I should be
looking for. If I do "up" a few times I see a section of main/dotcode.c
starting at line 180 (copied below) that looks like it might have a
problem. The first few cases do not have any PROTECT statements and
others do. If this is not a a good guess then perhaps someone could fill
me in on what statements that create new R objects look like.

Thanks,
Paul
_____
    case INTSXP:
 s = allocVector(type, n);
 iptr = (int*)p;
 for(i=0 ; i<n ; i++) {
     INTEGER(s)[i] = iptr[i];
 }
 break;
    case REALSXP:
 s = allocVector(type, n);
 if(asLogical(getAttrib(arg, CSingSymbol)) == 1) {
     sptr = (float*) p;
     for(i=0 ; i<n ; i++) REAL(s)[i] = (double) sptr[i];
 } else {
     rptr = (double*) p;
     for(i=0 ; i<n ; i++) REAL(s)[i] = rptr[i];
 }
 break;
    case CPLXSXP:
 s = allocVector(type, n);
 zptr = (Rcomplex*)p;
 for(i=0 ; i<n ; i++) {
     COMPLEX(s)[i] = zptr[i];
 }
 break;
    case STRSXP:
 if(Fort) {
     /* only return one string: warned on the R -> Fortran step */
     strncpy(buf, (char*)p, 255);
     buf[256] = '\0';
     PROTECT(s = allocVector(type, 1));
     SET_STRING_ELT(s, 0, mkChar(buf));
     UNPROTECT(1);
 } else ...

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._