[R] Segfaults of eigen

Juergen Rose rose at rz.uni-potsdam.de
Tue Jun 7 15:07:29 CEST 2011


Dear Prof. Ripley,

Am Montag, den 21.02.2011, 11:40 +0000 schrieb Prof Brian Ripley:
> So there is very likely a bug in your system software or compiler.
> There is no such problem on other x86_64 systems (including 
> Fedora 14 and 12, FreeBSD, Solaris and Windows).
> 
> You can debug segfaults for yourself (see 'Writing R Extensions') or 
> ask your vendor for support.

I still suffer from the same problem, but now with R version 2.12.2.

> On Mon, 21 Feb 2011, Juergen Rose wrote:
> 
> > Am Montag, den 21.02.2011, 11:11 +0100 schrieb Juergen Rose:
> >> Hi,
..
> >> With large(?) matrices eigen produces on several of my systems
> >> segfaults:
> >>
> >>> data(iris)
> >>> D <- dist(iris[,-5])
..
> >>> eigen(D)
> >>
> >>  *** caught segfault ***
> >> address (nil), cause 'unknown'
> >>
> >> Traceback:
> >>  1: .Call("La_rs", x, only.values, PACKAGE = "base")
> >>  2: eigen(D)

The problem happens only if blas-atlas and lapack-atlas are the current
libraries, it not happens with blas-reference and lapack-reference.

I tried also to follow 'Writing R Extensions', but I not really
understand, what I should do in my case. Have I to compile the libraries
and R with debugging information?

I tried without debugging information in R:
> data(iris)
> D <- dist(iris[,-5])
> debug(eigen)
> eigen(D)
debugging in: eigen(D)
debug: {
    x <- as.matrix(x)
    if (!is.null(dimnames(x))) 
        dimnames(x) <- list(NULL, NULL)
    n <- nrow(x)
    if (!n) 
        stop("0 x 0 matrix")
    if (n != ncol(x)) 
        stop("non-square matrix in 'eigen'")
    complex.x <- is.complex(x)
    if (!complex.x && !is.double(x)) 
        storage.mode(x) <- "double"
    if (!all(is.finite(x))) 
        stop("infinite or missing values in 'x'")
    if (missing(symmetric)) 
        symmetric <- isSymmetric.matrix(x)
    if (!EISPACK) {
        if (symmetric) {
            z <- if (!complex.x) 
                .Call("La_rs", x, only.values, PACKAGE = "base")
            else .Call("La_rs_cmplx", x, only.values, PACKAGE = "base")
            ord <- rev(seq_along(z$values))
        }
        else {
            z <- if (!complex.x) 
                .Call("La_rg", x, only.values, PACKAGE = "base")
            else .Call("La_rg_cmplx", x, only.values, PACKAGE = "base")
            ord <- sort.list(Mod(z$values), decreasing = TRUE)
        }
        return(list(values = z$values[ord], vectors = if (!only.values)
z$vectors[, 
            ord, drop = FALSE]))
    }
    dbl.n <- double(n)
    if (symmetric) {
        if (complex.x) {
            xr <- Re(x)
            xi <- Im(x)
            z <- .Fortran("ch", n, n, xr, xi, values = dbl.n, 
                !only.values, vectors = xr, ivectors = xi, dbl.n, 
                dbl.n, double(2 * n), ierr = integer(1L), PACKAGE =
"base")
            if (z$ierr) 
                stop(gettextf("'ch' returned code %d in 'eigen'", 
                  z$ierr), domain = NA)
            if (!only.values) 
                z$vectors <- matrix(complex(real = z$vectors, 
                  imaginary = z$ivectors), ncol = n)
        }
        else {
            z <- .Fortran("rs", n, n, x, values = dbl.n, !only.values, 
                vectors = x, dbl.n, dbl.n, ierr = integer(1L), 
                PACKAGE = "base")
            if (z$ierr) 
                stop(gettextf("'rs' returned code %d in 'eigen'", 
                  z$ierr), domain = NA)
        }
        ord <- sort.list(z$values, decreasing = TRUE)
    }
    else {
        if (complex.x) {
            xr <- Re(x)
            xi <- Im(x)
            z <- .Fortran("cg", n, n, xr, xi, values = dbl.n, 
                ivalues = dbl.n, !only.values, vectors = xr, 
                ivectors = xi, dbl.n, dbl.n, dbl.n, ierr = integer(1L), 
                PACKAGE = "base")
            if (z$ierr) 
                stop(gettextf("'cg' returned code %d in 'eigen'", 
                  z$ierr), domain = NA)
            z$values <- complex(real = z$values, imaginary = z$ivalues)
            if (!only.values) 
                z$vectors <- matrix(complex(real = z$vectors, 
                  imaginary = z$ivectors), ncol = n)
        }
        else {
            z <- .Fortran("rg", n, n, x, values = dbl.n, ivalues =
dbl.n, 
                !only.values, vectors = x, integer(n), dbl.n, 
                ierr = integer(1L), PACKAGE = "base")
            if (z$ierr) 
                stop(gettextf("'rg' returned code %d in 'eigen'", 
                  z$ierr), domain = NA)
            ind <- z$ivalues > 0L
            if (any(ind)) {
                ind <- seq.int(n)[ind]
                z$values <- complex(real = z$values, imaginary = z
$ivalues)
                if (!only.values) {
                  z$vectors[, ind] <- complex(real = z$vectors[, 
                    ind], imaginary = z$vectors[, ind + 1])
                  z$vectors[, ind + 1] <- Conj(z$vectors[, ind])
                }
            }
        }
        ord <- sort.list(Mod(z$values), decreasing = TRUE)
    }
    list(values = z$values[ord], vectors = if (!only.values) z
$vectors[, 
        ord, drop = FALSE])
}
Browse[2]> start
function (x, ...) 
UseMethod("start")
<environment: namespace:stats>
Browse[2]> 

valgrind
How to proceed? I also tried to use valgrind:

rose at moose:/home/rose(7)$ R -d valgrind --vanilla
==15631== Memcheck, a memory error detector
==15631== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et
al.
==15631== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright
info
==15631== Command: /usr/lib64/R/bin/exec/R --vanilla
==15631== 

valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination
valgrind:  cannot be set up.  Details of the redirection are:
valgrind:  
valgrind:  A must-be-redirected function
valgrind:  whose name matches the pattern:      strlen
valgrind:  in an object with soname matching:   ld-linux-x86-64.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux-x86-64.so.2
valgrind:  
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers
valgrind:  for your Linux distribution to please in future ship a non-
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called)
valgrind:  that exports the above-named function using the standard
valgrind:  calling conventions for this platform.  The package you need
valgrind:  to install for fix (1) is called
valgrind:  
valgrind:    On Debian, Ubuntu:                 libc6-dbg
valgrind:    On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo
valgrind:  
valgrind:  Cannot continue -- exiting now.  Sorry.


That means for me with GENTOO, that I have to compile glibc with
debuginfo. Is it correct?


Regards



More information about the R-help mailing list