[R] "Error: bad value" problem

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Dec 18 01:42:32 CET 2008


Peter Dalgaard wrote:
> Rolf Turner wrote:
>>
>> 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!
>>
> 
> Unfortunately, there's at least on R Core member for which it does NOT 
> happen... Fedora 9 i686, R 2.8.0 and 2.8.1 RC (2008-12-15 r47214)
> 

Wrong, actually... It did happen when run with 2.8.0 and valgrind (but 
not without it). Unfortunately there were no errors from valgrind.... 
yuck!!!

....
 > a
Error: bad value
 >
 >
Save workspace image? [y/n/c]: n
==29050==
==29050== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 116 from 1)
==29050== malloc/free: in use at exit: 13,984,907 bytes in 10,061 blocks.
==29050== malloc/free: 117,023 allocs, 106,962 frees, 93,104,003 bytes 
allocated.
==29050== For counts of detected errors, rerun with: -v
==29050== searching for pointers to 10,061 not-freed blocks.
==29050== checked 14,502,208 bytes.
==29050==
==29050== LEAK SUMMARY:
==29050==    definitely lost: 0 bytes in 0 blocks.
==29050==      possibly lost: 0 bytes in 0 blocks.
==29050==    still reachable: 13,984,907 bytes in 10,061 blocks.
==29050==         suppressed: 0 bytes in 0 blocks.
==29050== Rerun with --leak-check=full to see details of leaked memory.
[

-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list