Ole F. Christensen
2006-Jan-02 13:05 UTC
[Rd] R crash with complex matrix algebra when using EISPACK=TRUE
Dear subscribers of R-devel I am experiencing that R crashes (further details are given below) in some complex matrix calculations when EISPACK=TRUE has been specified in eigen(). I discovered the behaviour some months ago just after the release of R-2.2.0, and it has been lying on my desk since. I apologise for not having nailed the problem down to a simple function call, but I thought I should better report the problem now instead of waiting. My hope is that someone will either spot the cause of the crash in a minute, or otherwise provide some help for me to investigate further. ## The code : source("http://www.daimi.au.dk/~olefc/TEST/fct.R") source("http://www.daimi.au.dk/~olefc/TEST/parm.crash.R") for(l.v in 1:4){ for(r.v in 1:4){ for(l.x in 1:4){ for(r.x in 1:4){ hvad <- inhomoWmat.complex(subst.ratematrix(parm.same.str.sym$Gamma[,,l.v,r.v]),subst.ratematrix(parm.same.str.sym$Gamma[,,l.x,r.x]), EISPACK=TRUE) print(c(l.v,r.v,l.x,r.x)) } } } } ## gives [1] 1 1 1 1 [1] 1 1 1 2 [1] 1 1 1 3 [1] 1 1 1 4 [1] 1 1 2 1 Segmentation fault ### whereas the code seems to work fine when EISPACK=FALSE : source("http://www.daimi.au.dk/~olefc/TEST/fct.R") source("http://www.daimi.au.dk/~olefc/TEST/parm.crash.R") for(l.v in 1:4){ for(r.v in 1:4){ for(l.x in 1:4){ for(r.x in 1:4){ hvad <- inhomoWmat.complex(subst.ratematrix(parm.same.str.sym$Gamma[,,l.v,r.v]),subst.ratematrix(parm.same.str.sym$Gamma[,,l.x,r.x]), EISPACK=FALSE) print(c(l.v,r.v,l.x,r.x)) } } } } ## works fine. ## There is some randomness in how and when the crash happens. ## The crash is either : Segmentation fault # *** glibc detected *** double free or corruption (!prev): 0x08aa7298 *** # or *** glibc detected *** free(): invalid pointer: 0x082bfd20 *** ## Seen on R-2.2-1 and R-2.2-0 . ## Not seen in R-2.1.1 ! ## I haven't investiated whether it happens on Windows also. ### A few details on the matrix calculations : The eigenvalue decomposition is done on 4 * 4 matrices where the rows sum to 0. The matrices may be on the edge of not being complex diagonalizable. version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 2.1 year 2005 month 12 day 20 svn rev 36812 language R Thanks in advance of any help. Ole Christensen -- Ole F. Christensen BiRC - Bioinformatics Research Center University of Aarhus
Prof Brian Ripley
2006-Jan-02 18:11 UTC
[Rd] R crash with complex matrix algebra when using EISPACK=TRUE
Try valgrind. That is reporting use outside arrays in rg, that is the non-complex case of eigen(). Otherwise, using gctorture(TRUE) will help precipitate the error. On Mon, 2 Jan 2006, Ole F. Christensen wrote:> > Dear subscribers of R-devel > > I am experiencing that R crashes (further details are given below) in > some complex matrix calculations when EISPACK=TRUE has been specified in > eigen(). > I discovered the behaviour some months ago just after the > release of R-2.2.0, and it has been lying on my desk since. > I apologise for not having nailed the problem down to a simple function > call, but I thought I should better report the problem now > instead of waiting. > My hope is that someone will either spot the cause > of the crash in a minute, or otherwise provide some help for me to > investigate further. > > > ## The code : > > > source("http://www.daimi.au.dk/~olefc/TEST/fct.R") > source("http://www.daimi.au.dk/~olefc/TEST/parm.crash.R") > > for(l.v in 1:4){ > for(r.v in 1:4){ > for(l.x in 1:4){ > for(r.x in 1:4){ > hvad <- > inhomoWmat.complex(subst.ratematrix(parm.same.str.sym$Gamma[,,l.v,r.v]),subst.ratematrix(parm.same.str.sym$Gamma[,,l.x,r.x]), > EISPACK=TRUE) > print(c(l.v,r.v,l.x,r.x)) > } > } > } > } > > > ## gives > > [1] 1 1 1 1 > [1] 1 1 1 2 > [1] 1 1 1 3 > [1] 1 1 1 4 > [1] 1 1 2 1 > Segmentation fault > > > > ### whereas the code seems to work fine when EISPACK=FALSE : > > > source("http://www.daimi.au.dk/~olefc/TEST/fct.R") > source("http://www.daimi.au.dk/~olefc/TEST/parm.crash.R") > > for(l.v in 1:4){ > for(r.v in 1:4){ > for(l.x in 1:4){ > for(r.x in 1:4){ > hvad <- > inhomoWmat.complex(subst.ratematrix(parm.same.str.sym$Gamma[,,l.v,r.v]),subst.ratematrix(parm.same.str.sym$Gamma[,,l.x,r.x]), > EISPACK=FALSE) > print(c(l.v,r.v,l.x,r.x)) > } > } > } > } > > ## works fine. > > > ## There is some randomness in how and when the crash happens. > ## The crash is either : > > Segmentation fault > > # > > *** glibc detected *** double free or corruption (!prev): 0x08aa7298 > *** > > # or > > *** glibc detected *** free(): invalid pointer: 0x082bfd20 *** > > > > ## Seen on R-2.2-1 and R-2.2-0 . > ## Not seen in R-2.1.1 ! > ## I haven't investiated whether it happens on Windows also. > > > ### A few details on the matrix calculations : > The eigenvalue decomposition is done on 4 * 4 matrices where the rows > sum to 0. > The matrices may be on the edge of not being complex diagonalizable. > > > version > _ > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 > language R > > > Thanks in advance of any help. > > Ole Christensen > > -- > Ole F. Christensen > BiRC - Bioinformatics Research Center > University of Aarhus > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >-- Brian D. Ripley, ripley at 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