Skip to content

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

8 messages · Iñaki Ucar, Peter Dunn, Merlise Clyde, Ph.D.

#
Wow: Thanks again.  You are going above and beyond I?aki which I appreciate greatly.

But same error message appears, even after fixing (both the relerr, which I had already attended to, and the lambda issue).

I have since initialised *every* variable in the subroutine  smallp  (even the *input* variables to some arbitrary value to try to work out what is causing the issue) yet the error persists. There surely cannot be any uninitialized variables now *every* var in the subroutine is explicitly initialised.

That tells me that there is nothing I can do to remove the error. If everything is initialised?

Frustrated? And wasting so much time!

Thanks for any help from anyone.

P.
On 30/Oct/17, 9:06 pm, "I?aki ?car" <i.ucar86 at gmail.com> wrote:
2017-10-30 0:54 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
    > 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.)

    Found it. "relerr" may be uninitialised because "w" is uninitialised
    in smallp (tweedie 2.2.5, line 2169).

    When you try to debug this kind of things, you must track not only
    explicit initialisations, but also all the assignments with possibly
    uninitialised variables.

    BTW, I also see:

    tweedie.f:335:0:

                 if ( funvalue .LT. exp(-lambda) ) then

    Warning: 'lambda' may be used uninitialized in this function
    [-Wmaybe-uninitialized]

    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.
#
2017-11-01 5:56 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
All I can say is that initialising both lambda and w (from CRAN
version) solved the issue for me. As a matter of fact, I did see
another message about uninitialised values, but the back trace was
empty (no function names, I mean), which means that the problem is
somewhere else.
If you set up a public repo (GitHub or similar) where everyone can see
your current code base and changes made, it would be easier to help.
It would be even easier if you check your changes using a public build
system and share the results here. I don't know whether win-builder
uses valgrind, but you can use r-hub (https://github.com/r-hub/rhub)
by G?bor Cs?rdi. There is a function rhub::check_with_valgrind which
requires no further explanation.

I?aki
1 day later
#
I?aki  and all

Well, thanks for pointers to rhub.  Wonderful.  Moving things to github, but have to go home now?

So, when I download CRAN code, initialise w and lambda (which workled for I?aki), and run

rhub::check_with_valgrind()

on the code, I get no errors (https://builder.r-hub.io/status/tweedie_2.2.5.tar.gz-c8873979fcf84b4f8a0a4d5a47175f63).


But running

R -d "valgrind  --tool=memcheck --leak-check=full --track-origins=yes" --vanilla  < tweedie-Ex.R

from the command line *still* gives me errors about ?Conditional jump or move depends on uninitialised value(s)? in the subroutine smallp?.

I?aki found no errors when w and lambda were initialised.  I find similar using rhub (no errors)? but running valgrind from the command line still throws the same errors.

What does one make of that?

Thanks for any more help.


P.

PS: Really appreciate the help. This is driving me crazy.


From: I?aki ?car <i.ucar86 at gmail.com>
Date: Wednesday, 1 November 2017 at 10:28 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?

2017-11-01 5:56 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
All I can say is that initialising both lambda and w (from CRAN
version) solved the issue for me. As a matter of fact, I did see
another message about uninitialised values, but the back trace was
empty (no function names, I mean), which means that the problem is
somewhere else.
If you set up a public repo (GitHub or similar) where everyone can see
your current code base and changes made, it would be easier to help.
It would be even easier if you check your changes using a public build
system and share the results here. I don't know whether win-builder
uses valgrind, but you can use r-hub (https://github.com/r-hub/rhub)
by G?bor Cs?rdi. There is a function rhub::check_with_valgrind which
requires no further explanation.

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.
#
2017-11-03 6:01 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
That's impossible. Did you rebuild and reinstall the package after
making those changes?

I?aki
2 days later
#
Impossible or not? it just happened (unless I am being really stupid, which is entirely possible, indeed probable).  I confirmed again this morning: After rebuilding (R CMD build) and checking (R CMD check) without any errors, I used rhub and the command line again:


Running valgrind at the command line, I get this error:

==5097== Conditional jump or move depends on uninitialised value(s)
==5097==    at 0x1118F61FB: smallp_ (in /Users/pdunn2/Library/R/3.4/library/tweedie/libs/tweedie.so)

?when I am here:

$ pwd
/Users/pdunn2/Documents/Research/Rpackages/tweedie/tweedie-debug/CRAN-update/tweedie.Rcheck



In rhub:

check_with_valgrind("tweedie")

gives:

?? 0 errors ? | 0 warnings ? | 0 notes ?
?  Done with R CMD check
?  Saving artifacts

?when I am here:
[1] "/Users/pdunn2/Documents/Research/Rpackages/tweedie/tweedie-debug/CRAN-update"




I will take this to mean that there really is no problem? and put this down to things I don?t understand and ?experience?.

Thanks for everyone?s help.

P.

From: I?aki ?car <i.ucar86 at gmail.com>
Date: Friday, 3 November 2017 at 7:45 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?

2017-11-03 6:01 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
That's impossible. Did you rebuild and reinstall the package after
making those changes?

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.
#
2017-11-06 0:09 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
What I meant is that, if you run the script in tweedie.Rcheck from the
command line, Rscript uses your *installed* version of tweedie, not
the tarball you built with R CMD build. So if you didn't run R CMD
INSTALL, Rscript is running an old version without any fix, hence the
disagreement with R CMD check.

I?aki
#
?unless I am being really stupid?

Lucky for that caveat. Feeling rather stupid for this late effort.

Thanks so much.  Help greatly appreciated.

P.
On 6/Nov/17, 9:51 am, "I?aki ?car" <i.ucar86 at gmail.com> wrote:
2017-11-06 0:09 GMT+01:00 Peter Dunn <PDunn2 at usc.edu.au>:
    > Impossible or not? it just happened (unless I am being really stupid, which
    > is entirely possible, indeed probable). I confirmed again this morning:
    > After rebuilding (R CMD build) and checking (R CMD check) without any
    > errors, I used rhub and the command line again:
    >
    >
    > Running valgrind at the command line, I get this error:
    >
    > ==5097== Conditional jump or move depends on uninitialised value(s)
    > ==5097== at 0x1118F61FB: smallp_ (in
    > /Users/pdunn2/Library/R/3.4/library/tweedie/libs/tweedie.so)

    What I meant is that, if you run the script in tweedie.Rcheck from the
    command line, Rscript uses your *installed* version of tweedie, not
    the tarball you built with R CMD build. So if you didn't run R CMD
    INSTALL, Rscript is running an old version without any fix, hence the
    disagreement with R CMD check.

    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.