chisqsim broken on alpha (was Re: axis() produces junk on DEC alpha (PR#274))

Albrecht Gebhardt albrecht.gebhardt@uni-klu.ac.at
Tue, 14 Sep 1999 20:24:15 +0100 (GMT+0100)


On 14 Sep 1999, Peter Dalgaard BSA wrote:

> Albrecht Gebhardt <albrecht.gebhardt@uni-klu.ac.at> writes:
> 
> > this point? base-Ex.Rout is quite large, 4154 lines.
> > .... stop, now I got it, its a memory problem:
> > Running all help() examples ...
> > ../../bin/R --vanilla < base-Ex.R > base-Ex.Rout
> > /bin/sh: 303 Memory fault
> > make[3]: *** [base-Ex.Rout] Error 139
> > make[3]: Leaving directory
> > `/usr/local/src/redhat/BUILD/R-0.65.0/tests/Examples'
> > make[2]: *** [test-Examples] Error 2
> > make[2]: Leaving directory `/usr/local/src/redhat/BUILD/R-0.65.0/tests'
> > make[1]: *** [test-All] Error 2
> > make[1]: Leaving directory `/usr/local/src/redhat/BUILD/R-0.65.0/tests'
> > make: *** [test-All] Error 2
> > I have to go to another machine, my alpha at home as only 256MB, and swap
> > space is also very small.
> > Or should I run the tests with memory specifications from command line? 
> 
> Shouldn't be necessary with the current defaults 256MB should be
> plenty. 
> 
> Sometimes output buffers don't flush, so what is the last line of
> 
>  ../../bin/R --vanilla < base-Ex.R
> 

You were right, I found a next bug for R on alpha:

chisqsim (called from chisq.test() crashes. First I found that the crash
is at 
chisqsim.c:167
167             fact[i] = x;

but after placing a breakpoint here I could go some lines further and
reach
chisqsim.c:72
72                  x = exp(fact[iap - 1] + fact[ib] + fact[ic] +

The following is a log of my gdb-session: 

root@delta[Examples]# ../../bin/R --vanilla < base-Ex.R   
...
> x <- matrix(c(12, 5, 7, 7), nc = 2)
> chisq.test(x)$p.value           # 0.4233
[1] 0.4233054
> chisq.test(x, simulate.p.value = TRUE, B = 10000)$p.value
Segmentation fault (core dumped)
root@delta[Examples]# gdb -c core ../../bin/R.X11 -d ../../src/nmath/ -d ../../src/main/ -d ../../src/appl/
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "alphaev56-dec-osf4.0d"...
Core was generated by `R.X11'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/shlib/libSM.so...done.
Reading symbols from /usr/shlib/libICE.so...done.
Reading symbols from /usr/shlib/libX11.so...done.
Reading symbols from /usr/shlib/libdnet_stub.so...done.
Reading symbols from /usr/shlib/libUfor.so...done.
Reading symbols from /usr/shlib/libfor.so...done.
Reading symbols from /usr/shlib/libFutil.so...done.
Reading symbols from /usr/shlib/libm.so...done.
Reading symbols from /usr/shlib/libots.so...done.
Reading symbols from /usr/local/lib/libreadline.so.3...done.
Reading symbols from /usr/local/lib/libncurses.so.4...done.
Reading symbols from /usr/shlib/libc.so...done.
Reading symbols from /usr/local/src/redhat/BUILD/R-0.65.0/library/eda/libs/eda.s
o...done.
---Type <return> to continue, or q <return> to quit---
#0  0x12010a280 in chisqsim (nrow=0x140ff92d0, ncol=0x140ff92c8,
    nrowt=0x140ff92c0, ncolt=0x140ff92b8, n=0x140ff92b0, b=0x140ff92a8,
    expected=0x140ff9288, observed=0x140ff9278, fact=0x140ff9178,
    jwork=0x140ff9170, results=0x140fe58f0) at chisqsim.c:167
167             fact[i] = x;
(gdb) set env R_HOME /usr/local/src/redhat/BUILD/R-0.65.0
(gdb) break chisqsim.c:167
(gdb) run
Starting program: /usr/local/src/redhat/BUILD/R-0.65.0/tests/Examples/../../bin/R.X11

R : Copyright 1999, The R Development Core Team
Version 0.65.0  (August 27, 1999)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type    "?license" or "?licence" for distribution details.

R is a collaborative project with many contributors.
Type    "?contributors" for a list.

Type    "demo()" for some demos, "help()" for on-line help, or
        "help.start()" for a HTML browser interface to help.
Type    "q()" to quit R.

>  x <- matrix(c(12, 5, 7, 7), nc = 2)
> chisq.test(x)$p.valu
[1] 0.4233054
> chisq.test(x, simulate.p.value = TRUE, B = 10000)$p.value 

Breakpoint 1, chisqsim (nrow=0x140ff9ed8, ncol=0x140ff9ed0, nrowt=0x140ff9ec8,
    ncolt=0x140ff9ec0, n=0x140ff9eb8, b=0x140ff9eb0, expected=0x140ff9e90,
    observed=0x140ff9e80, fact=0x140ff9d80, jwork=0x140ff9d78,
    results=0x140fe64f8) at chisqsim.c:167
167             fact[i] = x;
(gdb) print x
$1 = 0
(gdb) print fact
$2 = (double *) 0x140ff9d80
(gdb) print *fact
$3 = 0
(gdb) step
165         for (i = 1; i <= *n; ++i) {
(gdb)
168         }
.....
(gdb) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x120109e24 in rcont2 (nrow=0x140ff9ed8, ncol=0x140ff9ed0, nrowt=0x140ff9ec0,
    ncolt=0x140ff9eb8, ntotal=0x140ff9eb8, fact=0x140ff9d80,
    jwork=0x140ff9d70, matrix=0x140ff9e68) at chisqsim.c:72
72                  x = exp(fact[iap - 1] + fact[ib] + fact[ic] +
(gdb) print x
$7 = 0
(gdb) print iap
$8 = 51539607572
(gdb) print ib
$9 = -51539607540
(gdb) print ic
$10 = -60129542130
(gdb) list
67                  idp = id + 1;
68                  igp = idp - nlm;
69                  ihp = iap - nlm;
70                  nlmp = nlm + 1;
71                  iip = ii + nlmp;
72                  x = exp(fact[iap - 1] + fact[ib] + fact[ic] +
73                          fact[idp - 1] - fact[ie] - fact[nlmp - 1] -
74                          fact[igp - 1] - fact[ihp - 1] - fact[iip - 1]);
75                  if (x >= dummy) {
76                      goto L160;
(gdb) print nlmp
$11 = 65117246112
(gdb) print iip
$12 = -46551903589
(gdb) print igp
$13 = -4987703949
(gdb) print ihp
$14 = -13577638539
(gdb) print id
$15 = 60129542161
(gdb) print nlm
$16 = 65117246111
(gdb) q
The program is running.  Exit anyway? (y or n) y


Albrecht

......................................................................
| Albrecht Gebhardt          Tel.: (++43 463) 2700/837               |
| Institut fuer Mathematik   Fax : (++43 463) 2700/834               |
| Universitaet Klagenfurt    mailto:albrecht.gebhardt@uni-klu.ac.at  |
| Villacher Str. 161         http://www-stat.uni-klu.ac.at/~agebhard |
| A-9020 Klagenfurt, Austria                                         |
`--------------------------------------------------------------------'

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