Dear R-help, Like several other subscribers, I have recently encountered a problem whereby R will execute code apparently correctly and without error, but any subsequent command will yield "Error: bad value" so that R has to be killed and restarted. We have checked this out with a few different operating systems (Windows XP/Vista and Linux) and with different versions of R. We have established the following: 1. The error occurs with versions of R from 2.5.0 onwards on all the OSs we have tried, but not with earlier versions of R. 2. The error is not reproducable between machines - identical code will fail at different points on two different machines. 3. The error is not related to contributed packages, because our code doesn't use any. The code *does*, however, use repeated calls to optim() and nlm(), and passes several arguments through a sequence of functions using "...". 4. Occasionally, we get an error relating to subset replacement instead of "Error:bad value". For example: > x <- rnorm(10) > x[1] <- 3 Error in x[1] <- 3 : could not find function "[<-" 5. The error behaviour changes as a result of minor modifications to print() statements in the code e.g. by inserting a line that prints the value of a well-defined variable. I suspect this really *is* a bug (particularly since it only started happening with version 2.5.0), but I figure it would be worth giving people a chance to tell me I'm an idiot before reporting it as such. In case anybody would like to try and see the error for themselves, I have uploaded some files to http://www.homepages.ucl.ac.uk/~ucakarc/Rtest/. The file ErrorDemo.r is the main script - see the file header there for more details. Files momfit.r and elmstats.dat are also required for this example to work. I'm sorry that it isn't a very simple example, but I haven't seen a simple illustration of the problem (and I couldn't find any examples in the list archives either). With best wishes to all, Richard ==================================================================== Richard E. Chandler ^^^^^^^^^^^^^^^^^^^ Room 135, Dept of Statistical Science, University College London, 1-19 Torrington Place, London WC1E 6BT, UK Tel: +44 (0)20 7679 1880 Fax: +44 (0)20 7383 4703 Internet: http://www.ucl.ac.uk/Stats (department) http://www.homepages.ucl.ac.uk/~ucakarc (personal) email: richard at stats.ucl.ac.uk
On 18/12/2008, at 11:34 AM, Richard E. Chandler wrote:> Dear R-help, > > Like several other subscribers, I have recently encountered a problem > whereby R will execute code apparently correctly and without error, > but any subsequent command will yield "Error: bad value" so that R > has to be killed and restarted. We have checked this out with a few > different operating systems (Windows XP/Vista and Linux) and with > different versions of R. We have established the following: > > 1. The error occurs with versions of R from 2.5.0 onwards on all the > OSs we have tried, but not with earlier versions of R. > 2. The error is not reproducable between machines - identical code > will fail at different points on two different machines. > 3. The error is not related to contributed packages, because our code > doesn't use any. The code *does*, however, use repeated calls to > optim() and nlm(), and passes several arguments through a sequence of > functions using "...". > 4. Occasionally, we get an error relating to subset replacement > instead of "Error:bad value". For example: > >> x <- rnorm(10) >> x[1] <- 3 > Error in x[1] <- 3 : could not find function "[<-" > > 5. The error behaviour changes as a result of minor modifications to > print() statements in the code e.g. by inserting a line that prints > the value of a well-defined variable. > > I suspect this really *is* a bug (particularly since it only started > happening with version 2.5.0), but I figure it would be worth giving > people a chance to tell me I'm an idiot before reporting it as such. > In case anybody would like to try and see the error for themselves, I > have uploaded some files to > http://www.homepages.ucl.ac.uk/~ucakarc/Rtest/. The file ErrorDemo.r > is the main script - see the file header there for more details. > Files momfit.r and elmstats.dat are also required for this example to > work. I'm sorry that it isn't a very simple example, but I haven't > seen a simple illustration of the problem (and I couldn't find any > examples in the list archives either).I can confirm that the error occurs. I downloaded the files and sourced ``ErrorDemo.R''. Doing x <- rnorm(10) after doing so triggered the error. Subsequently attempting traceback() (or anything else) simply triggered the error again. Good luck to R Core in tracking this down! cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
On 17/12/2008 5:34 PM, Richard E. Chandler wrote:> Dear R-help, > > Like several other subscribers, I have recently encountered a problem > whereby R will execute code apparently correctly and without error, > but any subsequent command will yield "Error: bad value" so that R > has to be killed and restarted. We have checked this out with a few > different operating systems (Windows XP/Vista and Linux) and with > different versions of R. We have established the following:The symptoms you describe suggest an out of bounds read or write. Unfortunately, I don't see the error, in R-devel or R 2.8.0. Tracking this sort of bug down on Windows is pretty hard, because as far as I know valgrind doesn't run on Windows, and I don't know of any Windows equivalent that supports gcc. So I'm not going to be able to help...other than to suggest reducing the example to something that runs quickly, then try running it after running gctorture(). That often flushes out hard to reproduce bugs, but it goes very slowly... Duncan Murdoch> > 1. The error occurs with versions of R from 2.5.0 onwards on all the > OSs we have tried, but not with earlier versions of R. > 2. The error is not reproducable between machines - identical code > will fail at different points on two different machines. > 3. The error is not related to contributed packages, because our code > doesn't use any. The code *does*, however, use repeated calls to > optim() and nlm(), and passes several arguments through a sequence of > functions using "...". > 4. Occasionally, we get an error relating to subset replacement > instead of "Error:bad value". For example: > > > x <- rnorm(10) > > x[1] <- 3 > Error in x[1] <- 3 : could not find function "[<-" > > 5. The error behaviour changes as a result of minor modifications to > print() statements in the code e.g. by inserting a line that prints > the value of a well-defined variable. > > I suspect this really *is* a bug (particularly since it only started > happening with version 2.5.0), but I figure it would be worth giving > people a chance to tell me I'm an idiot before reporting it as such. > In case anybody would like to try and see the error for themselves, I > have uploaded some files to > http://www.homepages.ucl.ac.uk/~ucakarc/Rtest/. The file ErrorDemo.r > is the main script - see the file header there for more details. > Files momfit.r and elmstats.dat are also required for this example to > work. I'm sorry that it isn't a very simple example, but I haven't > seen a simple illustration of the problem (and I couldn't find any > examples in the list archives either). > > With best wishes to all, > Richard > ====================================================================> Richard E. Chandler > ^^^^^^^^^^^^^^^^^^^ > Room 135, Dept of Statistical Science, University College London, > 1-19 Torrington Place, London WC1E 6BT, UK > Tel: +44 (0)20 7679 1880 Fax: +44 (0)20 7383 4703 > > Internet: http://www.ucl.ac.uk/Stats (department) > http://www.homepages.ucl.ac.uk/~ucakarc (personal) > email: richard at stats.ucl.ac.uk > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
>by Ben Bolker Dec 18, 2008; 01:36am :: Rate this Message: > > I can get the errors to happen on Ubuntu 8.10 with R --vanilla > (*without* valgrind) -- but editing momfit.r line 742 so that > plot.progress=FALSE seems to make the problem go away. (This was a > lucky guess, it looked like there was something odd going on with the plots.)Thanks for this. I can confirm that this appears to be correct (although you don't need to edit momfit - just add plot.progress=FALSE in the call to auto.fit() in ErrorDemo.r). As Peter D says, it doesn't exactly help to *find* the problem, but it does mean that my PhD student can continue with his work for the moment without going back to Rv2.4.1! With best wishes to all, Richard ==================================================================== Richard E. Chandler ^^^^^^^^^^^^^^^^^^^ Room 135, Dept of Statistical Science, University College London, 1-19 Torrington Place, London WC1E 6BT, UK Tel: +44 (0)20 7679 1880 Fax: +44 (0)20 7383 4703 Internet: http://www.ucl.ac.uk/Stats (department) http://www.homepages.ucl.ac.uk/~ucakarc (personal) email: richard at stats.ucl.ac.uk