From edd at debian.org  Thu Jan 29 05:26:18 2009
From: edd at debian.org (Dirk Eddelbuettel)
Date: Wed, 28 Jan 2009 22:26:18 -0600
Subject: [Rd] Side-effects of require() vs library() on x86_64 aka amd64
Message-ID: <18817.12266.512527.675087@ron.nulle.part>


RDieHarder fails its regression tests on x86_64 (aka "amd64") at CRAN (using
Debian), and I see the same on Ubuntu 8.10 in 64 bit.  No issues on 32bit.

One odd thing is that the program behaves well if run via

    R --no-save < tests/RDieHarder.R

but NOT when started using 

    R --slave < tests/RDieHarder.R

as R CMD check does.

So I tried different things related to startup options, --vanilla, etc pp. No
luck, no change.  And I just poked around with gdb, valgrind, ... without
much luck until I noticed that

   echo 'library(RDieHarder); dh <- dieharder("rand", "runs", seed=12345); \
   	 print(summary(dh))' | R --slave

works whereas the test fails if run as encoded in tests/RDieHarder.R, ie as, 

   echo 'require(RDieHarder, quiet=TRUE); dh <- dieharder("rand", "runs", seed=12345); \
   	 print(summary(dh))' | R --slave

[ What actually happens is that the right result gets computed either way by
DieHarder (as verbose=TRUE shows), but incorrect data gets returned to R for
subsequent tests by R ]

So what side-effects does require() have that library() does not have ?  

How can I make my package robust to this side-effect?

Thanks for any pointers, Dirk

-- 
Three out of two people have difficulties with fractions.



[Rd] Side-effects of require() vs library() on x86_64 aka amd64
Dirk Eddelbuettel