From ripley at stats.ox.ac.uk  Tue Jul 25 17:44:42 2006
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Tue, 25 Jul 2006 17:44:42 +0200 (CEST)
Subject: [Rd] valgrind complains about save (PR#9096)
Message-ID: <20060725154442.5CD35EF02@slim.kubism.ku.dk>

Please read the src/extra/zlib/deflate.c from line 1078: this is 
deliberate use of lookahead and explained there.  Valgrind is making a 
correct comment but the report is not of an error.

On Tue, 25 Jul 2006, charlie at stat.umn.edu wrote:

> valgrind complains about the save command in R 2.3.1 as shown by the
> script included below.  Of course, I don't know whether this "Conditional
> jump or move depends on uninitialised value(s)" is really a bug.
> Experience with similar issues in my own code says it may be, but it
> is also hard to tell.  Having no familiarity with the code cited
> in deflate.c, I leave the issue to experts.  Just thought someone
> should know.  Note that despite the printout in foo.Rout being a bit
> unclear about exactly where the purported bug occurs, there is no error
> reported in bar.Rout which does not have the save command.
> 
> Irrelevant to the bug, but this was originally spotted when package
> checking the aster package, which happened to have a save in tests/predict.R.
> 
> Script started on Tue 25 Jul 2006 09:59:59 AM CDT
> oak$ cat /etc/SuSE-release
> SUSE LINUX 10.1 (X86-64)
> VERSION = 10.1
> oak$ export VALGRIND_OPTS="--tool=memcheck"
> oak$ R CMD BATCH --vanilla --debugger=valgrind foo.R
> oak$ R CMD BATCH --vanilla --debugger=valgrind bar.R
> oak$ cat foo.R
> 
>  foo <- 2
>  save(foo, file = "foo.Rdata")
> 
> oak$ cat foo.Rout
> ==13521== Memcheck, a memory error detector.
> ==13521== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
> ==13521== Using LibVEX rev 1575, a library for dynamic binary translation.
> ==13521== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
> ==13521== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
> ==13521== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
> ==13521== For more details, rerun with: -v
> ==13521== 
> 
> R : Copyright 2006, The R Foundation for Statistical Computing
> Version 2.3.1 (2006-06-01)
> ISBN 3-900051-07-0
> 
> 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.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
> ==13521== Conditional jump or move depends on uninitialised value(s)
> ==13521==    at 0x5D2740: longest_match (deflate.c:1121)
> ==13521==    by 0x5D3BB6: deflate_slow (deflate.c:1595)
> ==13521==    by 0x5D30EB: deflate (deflate.c:790)
> ==13521==    by 0x5D4D21: do_flush (gzio.c:757)
> ==13521==    by 0x5D4F39: gzclose (gzio.c:991)
> ==13521==    by 0x44AC22: gzfile_close (connections.c:1035)
> ==13521==    by 0x44A703: con_close1 (connections.c:2256)
> ==13521==    by 0x44A742: con_close (connections.c:2283)
> ==13521==    by 0x44D3A3: do_close (connections.c:2303)
> ==13521==    by 0x4C43BB: do_internal (names.c:1089)
> ==13521==    by 0x4978F5: Rf_eval (eval.c:398)
> ==13521==    by 0x497F0D: Rf_evalList (eval.c:1400)
> > invisible(options(echo = TRUE))
> > 
> >  foo <- 2
> >  save(foo, file = "foo.Rdata")
> > 
> > 
> > proc.time()
> [1] 22.509  0.216 21.774  0.004  0.004
> > 
> ==13521== 
> ==13521== ERROR SUMMARY: 9 errors from 1 contexts (suppressed: 12 from 1)
> ==13521== malloc/free: in use at exit: 22,019,365 bytes in 10,911 blocks.
> ==13521== malloc/free: 37,822 allocs, 26,911 frees, 55,922,125 bytes allocated.
> ==13521== For counts of detected errors, rerun with: -v
> ==13521== searching for pointers to 10,911 not-freed blocks.
> ==13521== checked 18,666,336 bytes.
> ==13521== 
> ==13521== LEAK SUMMARY:
> ==13521==    definitely lost: 667 bytes in 35 blocks.
> ==13521==      possibly lost: 0 bytes in 0 blocks.
> ==13521==    still reachable: 22,018,698 bytes in 10,876 blocks.
> ==13521==         suppressed: 0 bytes in 0 blocks.
> ==13521== Use --leak-check=full to see details of leaked memory.
> oak$ cat bar.R
> 
>  foo <- 2
> 
> oak$ cat bar.Rout
> ==13534== Memcheck, a memory error detector.
> ==13534== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
> ==13534== Using LibVEX rev 1575, a library for dynamic binary translation.
> ==13534== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
> ==13534== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
> ==13534== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
> ==13534== For more details, rerun with: -v
> ==13534== 
> 
> R : Copyright 2006, The R Foundation for Statistical Computing
> Version 2.3.1 (2006-06-01)
> ISBN 3-900051-07-0
> 
> 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.
> 
>   Natural language support but running in an English locale
> 
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
> 
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
> 
> > invisible(options(echo = TRUE))
> > 
> >  foo <- 2
> > 
> > 
> > proc.time()
> [1] 22.169  0.204 21.422  0.004  0.004
> > 
> ==13534== 
> ==13534== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 12 from 1)
> ==13534== malloc/free: in use at exit: 21,998,613 bytes in 10,896 blocks.
> ==13534== malloc/free: 37,788 allocs, 26,892 frees, 55,576,442 bytes allocated.
> ==13534== For counts of detected errors, rerun with: -v
> ==13534== searching for pointers to 10,896 not-freed blocks.
> ==13534== checked 18,645,696 bytes.
> ==13534== 
> ==13534== LEAK SUMMARY:
> ==13534==    definitely lost: 667 bytes in 35 blocks.
> ==13534==      possibly lost: 0 bytes in 0 blocks.
> ==13534==    still reachable: 21,997,946 bytes in 10,861 blocks.
> ==13534==         suppressed: 0 bytes in 0 blocks.
> ==13534== Use --leak-check=full to see details of leaked memory.
> oak$ exit
> 
> Script done on Tue 25 Jul 2006 10:03:20 AM CDT
> 

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



[Rd] valgrind complains about save (PR#9096)
ripley at stats.ox.ac.uk