[R-pkg-devel] Package valgrind problem I can't solve: Direction?

Peter Dunn PDunn2 at usc.edu.au
Mon Oct 30 00:54:54 CET 2017


Thanks for this direction.

But I am still confused, as the problem persists after attending to any possible issue: That piece of identified code only has four variables, and I can account for them all.

The two variables  its  and  aimrerr  are now explicitly initialised.  So they cannot be the problem.

The variables  maxit  and relerr  are inputs to the subroutine... and both are explicitly initialised in the only subroutine which calls  smallp.  So I can’t see how that can be a problem. (Clearly they cannot be initialised in the subroutine  smallp  or their input values are overwritten.)

Any more idea for where I should be looking, or how I can progress this?  Using the flags below when  gfortran  is called, with  -O0 –g included, produced no errors or warnings at all.

Thanks again.  I just don’t know how else to track down the error, and it’s driving me crazy.

P.



From: Iñaki Úcar <i.ucar86 at gmail.com>
Date: Thursday, 26 October 2017 at 7:38 pm
To: Peter Dunn <PDunn2 at usc.edu.au>
Cc: "r-package-devel at r-project.org" <r-package-devel at r-project.org>
Subject: Re: [R-pkg-devel] Package valgrind problem I can't solve: Direction?

Hi,

2017-10-26 5:16 GMT+02:00 Peter Dunn <PDunn2 at usc.edu.au>:
> Hi all
>
> I am trying to compile (on my Mac) an R package (tweedie) which includes Fortran 77 code. I’m not much of a programmer, but can still manage to write and update F77 code. I’m new to valgrind.
>
> In checking my package (which passes the build-and-check with no errors), I use valgrind like this:
>
> R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" --vanilla < tweedie-Ex.R
>
>
> …on my package example, which gives me a series of messages like this:
>
> ==53843== Conditional jump or move depends on uninitialised value(s)
> ==53843== at 0x1118F61FB: smallp_ (in /Users/pdunn2/Library/R/3.4/library/tweedie/libs/tweedie.so)
> ==53843== by 0xBFA4FB88FFFFFFEB: ???
> ==53843== by 0x3FF91CB2DA3A50E7: ???
> ==53843== by 0x104888757: ???
> ==53843== by 0xFFFFFFEC03E375AF: ???
> ==53843== by 0x3FE18C2EE1BE47CB: ???
> ==53843== by 0x104885DEF: ???
> ==53843== by 0x104885DF7: ???
> ==53843== by 0x3FE518F314C67BE7: ???
> ==53843== by 0x11364CEAF: ???
> ==53843== by 0x104885DBF: ???
> ==53843== by 0x100000007: ??? (in /Library/Frameworks/R.framework/Resources/bin/exec/R)
> ==53843== Uninitialised value was created by a stack allocation
> ==53843== at 0x1118F59A6: smallp_ (in /Users/pdunn2/Library/R/3.4/library/tweedie/libs/tweedie.so)

CRAN shows a complete backtrace:
https://www.stats.ox.ac.uk/pub/bdr/memtests/valgrind/tweedie/tweedie-Ex.Rout

According to it, the offending conditional jump seems to be this one:

if ( ( its .LT. 3 )
& .OR.
& ( ( its .LT. maxit ) .AND.
& ( abs(relerr) .GT. aimrerr )
& )
& ) then

> I can see the piece of R code in the example from which this comes. The subroutine smallp is mentioned in the second line of the output.
>
> I simply cannot find the issue. (Spent days looking so far.) There are only a few conditional jumps, and everything not passed to the subroutine smallp is initialised. I have checked the calls to smallp as well. I have compiled the fortran code separately (after wrapping into a complete program), with all kinds of flags:
>
> gfortran -O2 -fimplicit-none -Wall -Wline-truncation -Wcharacter-truncation -Wsurprising -Waliasing -Wunused-parameter -fwhole-file -fcheck=all -std=f2008 -pedantic -fbacktrace),

Did you try "-O0 -g" instead of "-O2"?

Regards,
Iñaki



USC, Locked Bag 4, Maroochydore DC, Queensland, 4558 Australia.
CRICOS Provider No: 01595D
Please consider the environment before printing this email.
This email is confidential. If received in error, please delete it from your system.

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list