[Rd] R crash with complex matrix algebra when using EISPACK=TRUE

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jan 3 12:56:18 CET 2006


Well, valgrind helps a lot more here: it points at lines 2131 and 2135-6 
of eigen.f, and using gdb shows those are called with NA = 0.

So it is a bug in EISPACK, and easy enough to fix -- now done.

On Tue, 3 Jan 2006, Ole F. Christensen wrote:

> Brain, Thank you very much for your help.
> Using gctorture I was able to produce a simple function call showing the
> problem.
>
>
> Gm <- rbind(c(-0.3194373786, 0.2444066686, 0.0428108831,  3.221983e-02),
>                     c(0.0002071301, -0.0003282719,  0.0001211418,
> 5.128830e-12),
>                     c(0.0621332005,  0.0545850010, -0.2098487035,
> 9.313050e-02),
>                     c(0.0280936142,  0.0586642184,  0.1658310277,
> -2.525889e-01)
> )
> print(Gm)
> temp <- eigen(Gm)
> print(temp)
> gctorture(TRUE)
> temp <- eigen(Gm, EISPACK = TRUE)
>
>
>
> ###
> # On my computer I get :
> ##
>
> > gctorture(TRUE)
> >
> > source("http://www.daimi.au.dk/~olefc/TEST/Gm.R")
> > print(Gm)
>              [,1]          [,2]          [,3]          [,4]
> [1,] -0.3194373786  0.2444066686  0.0428108831  3.221983e-02
> [2,]  0.0002071301 -0.0003282719  0.0001211418  5.128830e-12
> [3,]  0.0621332005  0.0545850010 -0.2098487035  9.313050e-02
> [4,]  0.0280936142  0.0586642184  0.1658310277 -2.525889e-01
> >
> > temp <- eigen(Gm)
> > print(temp)
> $values
> [1] -3.464342e-01+1.3161e-03i -3.464342e-01-1.3161e-03i
> [3] -8.933476e-02+0.0000e+00i  9.052031e-19+0.0000e+00i
>
> $vectors
>                          [,1]                      [,2]            [,3]
> [1,] -0.3419128709-0.03748199i -0.3419128709+0.03748199i -0.222056433+0i
> [2,]  0.0003508445+0.00001921i  0.0003508445-0.00001921i  0.001421758+0i
> [3,] -0.4179745717+0.01301547i -0.4179745717-0.01301547i -0.664932225+0i
> [4,]  0.8407249376+0.00000000i  0.8407249376+0.00000000i -0.713129761+0i
>        [,4]
> [1,] -0.5+0i
> [2,] -0.5+0i
> [3,] -0.5+0i
> [4,] -0.5+0i
>
> > temp <- eigen(Gm, EISPACK = TRUE)
> *** glibc detected *** free(): invalid pointer: 0x08c4e778 ***
> Aborted
>
>
>
> # Should I submit this as a bug report also ?
>
>
> Best
>
> Ole
>
>
>
> Prof Brian Ripley wrote:
>
>> 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
>>>
>>>
>>
>
> -- 
> 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



More information about the R-devel mailing list